<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edwin M Sarmiento&gt;Simple PING test: VBScript vs PowerShell &#8211; Edwin M Sarmiento</title>
	<atom:link href="https://www.edwinmsarmiento.com/simple-ping-test-vbscript-vs-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.edwinmsarmiento.com</link>
	<description>Intentional Excellence</description>
	<lastBuildDate>Mon, 13 Apr 2026 21:00:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">84283043</site>		<item>
		<title>&gt;Simple PING test: VBScript vs PowerShell</title>
		<link>https://www.edwinmsarmiento.com/simple-ping-test-vbscript-vs-powershell/</link>
		<comments>https://www.edwinmsarmiento.com/simple-ping-test-vbscript-vs-powershell/#respond</comments>
		<pubDate>Thu, 03 Jul 2008 04:25:00 +0000</pubDate>
		<dc:creator>Edwin M Sarmiento</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://bassplayerdoc.wordpress.com/2008/07/03/simple-ping-test-vbscript-vs-powershell</guid>

				<description><![CDATA[&#62;As a preparation for my TechEd Asia 2008 session on Windows PowerShell, I&#8217;ve been trying to convert a few of my administrative scripts to demonstrate how easy tasks can be done using PowerShell. Here&#8217;s one I just did: simple PING test. Here&#8217;s a sample VBScript code that checks whether a PING test is successful or [&#8230;]]]></description>
					<content:encoded><![CDATA[<p>&gt;<span style="font-family:arial;">As a preparation for my TechEd Asia 2008 session on Windows PowerShell, I&#8217;ve been trying to convert a few of my administrative scripts to demonstrate how easy tasks can be done using PowerShell. Here&#8217;s one I just did: simple PING test. Here&#8217;s a sample VBScript code that checks whether a PING test is successful or not. I call the VBScript and pass it a parameter which is the hostname or IP address of the computer I want to ping</span><br /><span style="font-family:Arial;"></span><br /><span style="font-family:Arial;"><strong>VBScript:</strong></span><br /><code style="font-size:12px;"><span style="font-family:lucida grande;"><strong><span style="color:black;">strComputer</span><span style="color:blue;">=</span><span style="color:black;">Wscript.Arguments.Item</span><span style="color:gray;">(</span><span style="color:black;">0</span></strong></span><span style="font-family:lucida grande;"><strong><span style="color:gray;">) <span style="color:#009900;">'parameter passed = hostname</span></p>
<p></span><span style="color:black;">wmiQuery </span><span style="color:blue;">= </span><span style="color:darkred;">"Select * From Win32_PingStatus Where Address = '" </span><span style="color:gray;">&amp; </span><span style="color:black;">strComputer </span><span style="color:gray;">&amp; </span><span style="color:darkred;">"'" </span><span style="color:blue;"></span></strong></span></code><br /><code style="font-size:12px;"><span style="font-family:lucida grande;color:blue;"><strong></strong></span></code><br /><code style="font-size:12px;"><span style="font-family:lucida grande;"><strong><span style="color:blue;">Set </span><span style="color:black;">objWMIService </span><span style="color:blue;">= </span><span style="color:black;">GetObject</span><span style="color:gray;">(</span><span style="color:darkred;">"winmgmts:\.rootcimv2"</span></strong></span><span style="font-family:lucida grande;"><strong><span style="color:gray;">)<br /></span><span style="color:blue;">Set </span><span style="color:black;">objPing </span><span style="color:blue;">= </span><span style="color:black;">objWMIService.ExecQuery</span><span style="color:gray;">(</span><span style="color:black;">wmiQuery</span></strong></span><span style="font-family:lucida grande;"><strong><span style="color:gray;">)<br /></span><span style="color:blue;">For Each </span><span style="color:black;">objStatus </span><span style="color:blue;">In </span></strong></span><span style="font-family:lucida grande;"><strong><span style="color:black;">objPing<br /></span><span style="color:blue;">If </span><span style="color:black;">IsNull</span><span style="color:gray;">(</span><span style="color:black;">objStatus.StatusCode</span><span style="color:gray;">) </span><span style="color:blue;">Or </span><span style="color:black;">objStatus.Statuscode</span><span style="color:gray;"></span><span style="color:black;">0 </span></strong></span><span style="font-family:lucida grande;"><strong><span style="color:blue;">Then<br /></span><span style="color:black;">Reachable </span><span style="color:blue;">= False </span></strong></span><span style="font-family:lucida grande;color:green;"><strong>'if computer is unreacable, return false<br /></strong></span><span style="font-family:lucida grande;"><strong><span style="color:blue;">Else<br /></span><span style="color:black;">Reachable </span><span style="color:blue;">= True </span></strong></span><span style="font-family:lucida grande;color:green;"><strong>'if computer is reachable, return true<br /></strong></span><strong><span style="font-family:lucida grande;font-size:85%;color:blue;"><span style="font-size:100%;">End If<br />Next</span><br /></span><span style="color:black;"></span></strong></code><br /><span style="font-size:85%;"><span style="font-family:lucida grande;color:black;"><strong>Wscript.Echo Reachable</strong></span> </span><br /><span style="font-size:85%;"></span><br /><span style="font-family:arial;">Here&#8217;s the equivalent script using PowerShell</span><br /><span style="font-family:Arial;"></span><br /><strong><span style="font-family:lucida grande;font-size:85%;">Param($hostname)</span></strong><br /><strong><span style="font-family:lucida grande;font-size:85%;">$ping = new-object System.Net.NetworkInformation.Ping<br />$Reply = $ping.Send($hostname)</span></strong><br /><strong><span style="font-family:lucida grande;font-size:85%;">$Reply.status</span></strong><br /><strong><span style="font-size:85%;"></span></strong><br /><span style="font-family:arial;">You can see how much easier it is to accomplish a simple task in PowerShell. It makes the life of an administrator much better, especially if you have to write scripts that automate repetitive tasks. I&#8217;ll post more samples of the VBScript codes you&#8217;ve probably seen in this blog converted to PowerShell</span></p>
<div class="blogger-post-footer"><img width='1' height='1' src='' alt='' /></div>
]]></content:encoded>
			

		<wfw:commentRss>https://www.edwinmsarmiento.com/simple-ping-test-vbscript-vs-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
				<post-id xmlns="com-wordpress:feed-additions:1">112</post-id>	</item>
	</channel>
</rss>