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,943 views | 14/07/2012 21:52

Your Powershell scripts binding some ports to server ip address? Then you need to check ip address before to avoid from issues.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Confirm-PoSHServerIP
{
param ($IP)
 
	# Get Networking Adapter Configuration 
	$IPConfigs = Get-WmiObject Win32_NetworkAdapterConfiguration
 
	# Get All IP Addresses 
	foreach ($IPConfig in $IPConfigs) 
	{ 
		if ($IPConfig.IPaddress) 
		{ 
			foreach ($IPAddress in $IPConfig.IPaddress) 
			{ 
				if ("$IP" -eq "$IPAddress")
				{
					$Result = "Validated"
				}
			}
		}
	}
 
	$Result
}

If you get “Validated” as a output, then you can be sure that, ip address is exist on server.