search
Categories
Archive
Blogroll

Badges

Microsoft PowerShell MVP
MCSE
Sponsors

VirtualMetric
Cozumpark Bilisim Portali
Checking IP addresses of list of Server Names
Posted in Windows Powershell, Windows Server | 2 Comments | 569 views | 21/06/2013 09:49

You can check ip addresses of server names like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	$IPAddress = [System.Net.Dns]::GetHostAddresses("$Server").IPAddressToString
	If ($IPAddress -like "172.29*")
	{
		Write-Host "Test Server"
		Add-Content -Path C:\testservers.txt -Value $Server
	}
	else
	{
		Write-Host "Prod Server"
		Add-Content -Path C:\prodservers.txt -Value $Server
	}
}

As you see, i split them into 2 different groups.


Comments (2)

NeWay Technologies – Weekly Newsletter #48 – June 20, 2013 | NeWay

June 23rd, 2013
02:12:00

[...] Checking IP addresses of list of Server Names – [...]


NeWay Technologies – Weekly Newsletter #48 – June 21, 2013 | NeWay

June 23rd, 2013
02:16:15

[...] Checking IP addresses of list of Server Names – [...]



Leave a Reply