This function returns all linked servers information and make a connectivity teste to them.

I put the Save-SQLMsg also because it generates a log file to the servers that for some reason gave error. The connectivity test is done and returns true or false.

Examples

#all properties returneb by fucntion
LineNumber                  int,
Date                            datetime,
ServerName                  string,
LinkedServerName         string,
DataSource                   String,
DateLastModified           datetime,
CollationCompatible       boolean,
DataAccess                    boolean,
RPC                             boolean,
RpcOut                         boolean,
UseRemoteCollation       boolean,
CollationName               string,
ConnectionTimeOut        int,
QueryTimeOut               int,
Distributor                     boolean,
Publisher                      boolean,
Subscriber                     boolean,
LazySchemaValidation    boolean,
EnablePromotionofDistributedTransactionsForRPC  boolean,
ProviderName          string,
ProductName           string,
Connectivity            Boolean

List All LinkedServers Server Default
Get-SQLLinkedServer

List All LinkedServers All servers (by txt) (PUT THE SERVER AT TXT FILE)
Get-SQLLinkedServer "c:\temp\servers.txt"

List All LinkedServers All servers (by txt) (name and connectivity test )
Get-SQLLinkedServer "c:\temp\servers.txt" | select LineNumber,Date,ServerName,LinkedServerName,Connectivity |Format-Table

List All LinkedServers All servers (by txt) (name and connectivity test =false )
Get-SQLLinkedServer "c:\temp\servers.txt" | where-object {$_.Connectivity -eq $false} | select LineNumber,Date,ServerName,LinkedServerName,Connectivity |Format-Table

List all LinkedServers All servers (by txt) (name and connectivity test = false ) and stored SQL Server Table
TSQL create table (LinkedServers XML)

(Get-SQLLinkedServer "c:\temp\servers.txt" | where-object {$_.Connectivity -eq $false} | select LineNumber,Date,ServerName,LinkedServerName,Connectivity | ConvertTo-Xml -NoTypeInformation).save("c:\temp\LinkedServers.xml")
$XML = (Get-Content "C:\Temp\LinkedServers.xml" ) -replace "'", "''"
$SQL = "insert into LinkedServers (XML) values ('$XML')"
invoke-sqlcmd -ServerInstance $env:COMPUTERNAME -database "tempdb" -query $sql


 TSQL to list with servername  condition = "Jupiter"
Select t2.Col1.value('(Property[@Name="LineNumber"]/text())[1]', 'int') LineNumber,
    t2.Col1.value('(Property[@Name="Date"]/text())[1]', 'nvarchar(255)') Date,
    t2.Col1.value('(Property[@Name="ServerName"]/text())[1]', 'nvarchar(max)') ServerName,
    t2.Col1.value('(Property[@Name="LinkedServerName"]/text())[1]', 'nvarchar(255)') LinkedServerName,
    t2.Col1.value('(Property[@Name="Connectivity"]/text())[1]', 'nvarchar(255)') Connectivity
FROM dbo.LinkedServers
CROSS APPLY xml.nodes('/Objects/Object') As t2(Col1)
where t2.Col1.value('(Property[@Name="ServerName"]/text())[1]', 'nvarchar(max)') = 'Jupiter'

PowerShell
Edit|Remove
Function Save-SQLMsg () 
<#
----------------------------------------------------------
Save  log in file
----------------------------------------------------------
Requires POWERSHELL 2.0

File Name     			= $NamePS1
Server name   			= $Server 
DatabaseName 			= $databasename
Message To Log		    = $Message
Path to generate file 	= $PathFileLog 
Date to Log				= $TodayDate
#>


{

	[CmdletBinding()]
	
	Param (
		[Parameter(position=1,Mandatory = $true )][String] $NamePS1,
		[Parameter(position=2,Mandatory = $true )][String] $Server,
		[Parameter(position=3,Mandatory = $false )][String] $DatabaseName = "",
		[Parameter(position=4,Mandatory = $false )][String] $Message = "" ,
		[Parameter(position=5,Mandatory = $false )][String] $PathFileLog = "C:\temp1",
		[Parameter(position=6,Mandatory = $false )][String] $TodayDate = (Get-Date -Format "yyyyMMddhhmmss")
		)
	process 
	{
	
		#test if path wich will contains the error file exists. if not create 
	
	if (!(Test-Path -path $PathFileLog))
	{
		try {
			New-Item $PathFileLog -itemtype directory -ErrorAction  Stop   | Out-Null
		}
		catch {
			Write-Host "Can not create log file path"
			break;
		}
	} 
	
	
	$NameFileFull = $PathFileLog + "\" + $NamePS1 + $TodayDate + ".log" 
	
	$TDate = $TodayDate.Substring(0,4) + "-" + $TodayDate.Substring(4,2) + "-" + $TodayDate.Substring(6,2) 
	
	"Server : " + $Server + " Database : " + $DatabaseName + " Date : "  + $TDate + " Message: "  + $Message | Out-file  $NameFileFull -append 
	} 
}

Function Get-SQLLinkedServer()
<#
----------------------------------------------------------
Test All Linked Servers
----------------------------------------------------------
Requires POWERSHELL 2.0

$TXTServersList         = Txt with servers to be checked - Default server


#>
{
	[CmdletBinding()]
	
	PARAM	(
				[Parameter(position=1,Mandatory=$false, ValueFromPipelineByPropertyName=$true,HelpMessage="File Servers List")]
				[Alias("FullNameTXT")]
				[String] $TXTServersList = $env:COMPUTERNAME
				
			)

	begin 
	{
		[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null 
	}
	Process
	{
	
		$verbosePreference="continue" 
		[datetime] $TodayDate = get-date -Format "yyyy/MM/dd hh:mm:ss"
		if ($TXTServersList.substring($TXTServersList.length -4,4) -eq ".TXT")
		{
			try
			{
				$ServersList = get-content $TXTServersList	
			} catch {
						$msg = $error[0]
						Write-Warning $msg
						break;
			}
		}	
		else
		{
			$ServersList = $TXTServersList
		}	
		
		
		$LineNumber = 1
		$FinalResult = @()
	
		foreach ($svr in  $ServersList )
		{
			try 
			{
				$Server=New-Object "Microsoft.SqlServer.Management.Smo.Server" "$svr"
				$Data = $Server.linkedservers| where-object {$_.State -eq "Existing"} | foreach {
				
					$Object = New-Object PSObject
					
					[datetime]$DateLastModified = "{0:yyyy-MM-dd hh:mm:ss}" -f [datetime] $_.DateLastModified  
	
					$Object | add-member Noteproperty LineNumber  					$LineNumber 	
					$Object | add-member Noteproperty Date  						$TodayDate 	
					$Object | add-member Noteproperty ServerName  					$svr
					$Object | add-member Noteproperty LinkedServerName 				$_.Name
					$Object | add-member Noteproperty DataSource 					$_.DataSource 					
					$Object | add-member Noteproperty DateLastModified 				$DateLastModified
					$Object | add-member Noteproperty CollationCompatible 			$_.CollationCompatible
					$Object | add-member Noteproperty DataAccess 					$_.DataAccess
					$Object | add-member Noteproperty RPC		 					$_.RPC
					$Object | add-member Noteproperty RpcOut		 				$_.RPCOut
					$Object | add-member Noteproperty UseRemoteCollation			$_.UseRemoteCollation
					$Object | add-member Noteproperty CollationName					$_.CollationName					
					$Object | add-member Noteproperty ConnectionTimeOut				$_.ConnectTimeOut
					$Object | add-member Noteproperty QueryTimeOut					$_.QueryTimeOut					
					$Object | add-member Noteproperty Distributor	 				$_.Distributor					
					$Object | add-member Noteproperty Publisher 					$_.Publisher					
					$Object | add-member Noteproperty Subscriber 					$_.Subscriber										
					$Object | add-member Noteproperty LazySchemaValidation 			$_.LazySchemaValidation
					$Object | add-member Noteproperty EnablePromotionofDistributedTransactionsForRPC		$_.IsPromotionofDistributedTransactionsForRPCEnable					
					$Object | add-member Noteproperty ProviderName 					$_.ProviderName					
					$Object | add-member Noteproperty ProductName					$_.ProductName
					try
					{
						$_.testconnection() 
						$Object | add-member Noteproperty Connectivity				$True
					} catch {
						$Object | add-member Noteproperty Connectivity				$False
					}
					
					$FinalResult += $Object
					$LineNumber ++ 
				} 
	
			
			}	catch {		
						$msg = $error[0]
						Write-Warning $msg
						Save-SQLMsg "Get-SQLLinkedServer" "$svr" "" "$msg" 
						continue
			} 
			
		}
		
		Write-Output $FinalResult
	}	

}