How many times have you done this when testing network connectivity?
If all we want is a test of connectivity ping works fine. We can ping using WMI or .NET classes from within PowerShell. This has the advantage of returning an object rather than text which means we can work with it much easier.
$ping = New-Object -TypeName System.Net.NetworkInformation.Ping
This could be condensed to
$ping = (New-Object -TypeName System.Net.NetworkInformation.Ping).Send(“127.0.10.1”)
and we get the results in the ping variable.
The WMI solution is like this
Get-WmiObject -Class Win32_PingStatus -Filter “Address=’127.0.0.1′”
We can make this even easier because PowerShell 2 wraps this WMI class in a cmdlet
Test-Connection -ComputerName 127.0.0.1
if you don’t want to type all that then create an alias
Set-Alias -Name p -Value Test-Connection
just don’t use the alias in scripts