Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

finding IP address

$
0
0

I'm trying to use test-connection to find out the IP address of machines to see what subnet they are on.   I know test-connection contains the IP address yet I can't seem to check for it.  All of the following do NOT execute the write-host command 

$getip = (Test-Connection mg09822 -Count 1).IPV4Address

if ($getip -contains "*.64.*") {Write-Host "this is on .64"}

 

$getip = Test-Connection mg09822 -Count 1

if ($getip -contains "*.64.*") {Write-Host "this is on .64"}

 

$getip = (Test-Connection mg09822 -Count 1).IPV4Address

if ($getip -like "*.64.*") {Write-Host "this is on .64"}

 

$getip = Test-Connection mg09822 -Count 1

if ($getip -like "*.64.*") {Write-Host "this is on .64"}

 

Machine mg09822 is on the .64 subnet too.


Viewing all articles
Browse latest Browse all 6937

Trending Articles