|
Guy recommends :
Find out which of your VMs are a waste of space and which VMs need more resources.
|
PowerShell Test-ConnectionThe benefits of Test-Connection are two-fold, you can measure average response times, something that's not possible with ping, and you can employ Test-Connection as a vehicle for learning about PowerShell's mathematical cmdlets such as Measure-Object and [System:Math]. Topics for PowerShell Test-Connection
♣ Test-Connection Measures Response Time for WebsitePing has been the traditional command to test connectivity. My mission is to show how PowerShell can achieve better control through its cmdlet Test-Connection. Getting Started: Switch from Ping to Test-Connection Assumption: You not only have installed and setup PowerShell, but also it's PowerShell v 2.0 and not v 1.0. # PowerShell's Test-Connection - Equivalent of Ping # Now launch PowerShell and try: Benefits of Test-Connection Compared to Ping
This following script contains 3 elements: There is no doubt that you could make a much more efficient script, however my version pays homage to divide and rule. I believe that the easiest way to learn scripting is to break the task into chunks, then bolt all the bits together. Furthermore, my version encourages you to make alterations, for example, change the value of $Server and the number of tests to 'count'. # PowerShell script to measure a server's response time Note 1: Test-Connection is more flexible than Ping. You can research more properties for your scripts by prefixing Get-Help to Test-Connection, also try suffixing Get-Member. Note 2: ResponseTime is a property of Test-Connection, the benefit of using this PowerShell cmdlet rather than ping is that we can calculate average connection times. Note 3: At first sight [System.Math]:: seems a strange way to call for mathematical functions such as Round, Truncate or log, however you soon get used to its ways! Note 4: See more on Measure-Object Experiment: You cannot learn without making mistakes, try changing the parameters below, some will make no sense, while others will be predictable. Only by experimenting will you truly understand how to handle PowerShell's math functions. ResponseTime -Sum (Also -Maximum, -Count)
Guy
Recommends:
A Free Wake-On-LAN Utility
|
||||
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Home Copyright © 1999-2012 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |