There are a lot of things added to the CTP3 of Powershell, which I'll try write about over the next few weeks. Today I'll talk about one of the new cmdlets that really hasn't received much attention. I feel it's probably one of the most useful as a Sys Admin. The 'Test-Connection' cmdlet. It has some really useful parameters that can save you time before you try to execute some commands on that workstation that is powered off, or ping from a computer that is not your own.
The first useful parameter for the Test-Connection cmdlet is 'Count'. Not too surprising, what the count parameter does is determine how many ICMP requests to send to the destination address. Very useful if you want to only send 1 or 2 requests to the computer to check it's alive. If the count parameter is not specified a default of 4 request are sent.
Sjdelatorre@JDELATORRE {~} Test-Connection jdelatorrevm -Count 10
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
JDELATORRE jdelatorrevm 192.168.249.82 32 5
JDELATORRE jdelatorrevm 192.168.249.82 32 81
JDELATORRE jdelatorrevm 192.168.249.82 32 1
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 22
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 4
Sjdelatorre@JDELATORRE {~}
The 'Delay' parameter is another very useful parameter to cut down on the amount of traffic sent over the wire. I use this when rebooting a server and checking to see when it's back up, but instead of consistently pinging the server every second as with Ping.exe -t, you can specify how far apart you want those request. By default the delay is 1 second.
Here I'm pinging my virtual machine 4 times with 10 seconds between each ping request.
Sjdelatorre@JDELATORRE {~} Test-Connection jdelatorrevm -Delay 10
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 0
JDELATORRE jdelatorrevm 192.168.249.82 32 0
Sjdelatorre@JDELATORRE {~}
Probably the most interesting and sometimes most helpful is the 'Source' parameter. With the source parameter you can specify where your ping request originate from. So it's possible to test the connection speeds to other parts of your network from a server when typing the command at your computer. Here, I'm pinging my laptop but the requests are coming from my VM.
Sjdelatorre@JDELATORRE {~} Test-Connection -Source jdelatorrevm -Destination jdelatorre
Source Destination IPV4Address IPV6Address Bytes Time(ms)
------ ----------- ----------- ----------- ----- --------
JDELATORREVM jdelatorre 192.168.249.54 192.168.249.54 32 0
JDELATORREVM jdelatorre 192.168.249.54 192.168.249.54 32 0
JDELATORREVM jdelatorre 192.168.249.54 192.168.249.54 32 0
JDELATORREVM jdelatorre 192.168.249.54 192.168.249.54 32 0
Sjdelatorre@JDELATORRE {~}
There's quite a bit more to the Test-Connection cmdlet than what I've posted here, such as:
- AsJob
- Authentication
- BufferSize
- Credential
- Impersonation
- ThrottleLimit
- TimeToLive
So now you can call the Test-Connection cmdlet with just ping
ping jdelatorrevm
As a note. The data that is sent/returned is plain ol' WMI.
No comments:
Post a Comment