Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Putting it all together with PowerShell 29 Lastly, we increment the value in $counter by 1. Next, we can find the body of our loop enclosed in braces, {} . Inside the loop we are doing a very nice little bit of .NET work to call the ping function provided there. As PowerShell is a native Microsoft tool, it is fully capable of taking advantage of Microsoft's .NET development framework and all the goodies that come with it. In this particular case, we are instantiating an object to use for ping , running a ping against the host name or IP provided by our first argument, and sleeping for five seconds. After we finish sleeping, we will go back to the top of the loop, repeating this for a total of 10 times through. In the output, we will see the results of our pings display each time we execute the loop. We can also use another construct called a foreach loop, like so: $devices = @("codingforpentesters.com","happypacket.net") foreach ($device in $devices) { write-output "device is " $device $ping = New-Object System.Net.NetworkInformation.Ping $result = $ping.Send($device) $result