Quantcast
Channel: windows server – VM.Blog.
Viewing all articles
Browse latest Browse all 29

PowerShell script to find FQDN and get ping status of Windows Servers

$
0
0

### PowerShell script to find FQDN and get ping status for given list of windows servers
# Servers which we failed to connect to get any info are collected in to a txt file.
### Writing credits : VM ###
###########################################################################

$servers = Get-Content “D:\temp\test2.txt”

@(
foreach ($name in $servers)
{
if ( Test-Connection -ComputerName “$name.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.a.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.a.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.b.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.b.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.c.domain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.c.domain.com is up”}
elseif ( Test-Connection -ComputerName “$name.newdomain.com” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name.newdomain.com is up”}
#elseif ( Test-Connection -ComputerName “$name” -Count 1 -ErrorAction SilentlyContinue ) { Write-output “$name is up”}
else
{
Write “$name FQDN not found/ server is not pinging” | out-file -Append “D:\temp\failed-ping-1.txt” -NoClobber
}
}
) | Out-file -FilePath “D:\temp\FQDN-1.csv”


Viewing all articles
Browse latest Browse all 29

Trending Articles