search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 2,021 views | 21/06/2013 15:54

You can resolve ip addresses of many servers via Powershell.

1
2
3
4
5
6
7
8
9
10
11
12
$Servers = Get-Content C:\Servers.txt
foreach ($Server in $Servers)
{
	$IPAddress = $null
	$IPAddress = [System.Net.Dns]::GetHostAddresses("$Server").IPAddressToString
	Add-Content -Path C:\ServerName.txt -Value $Server
	if ($IPAddress -eq $null)
	{
		$IPAddress = "Server IP cannot resolve."
	}
	Add-Content -Path C:\ServerIP.txt -Value $IPAddress
}

It creates two different txt file, so you can merge them in an excel file.


Posted in Windows Powershell, Windows Server | 2 Comments | 2,228 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.