I have a script that pings computers within a certain OU in Active Directory. Any computer that responds to ping is then shutdown remotely with a 5 minute timer. Works Perfectly.

My shutdown script:

 Code:
;=================================================================
;  Shutdown Computers
;=================================================================

Dim $objAdsPath, $obj, $filter[0]
$filter[0] = "computer"
$objADsPath = GetObject("LDAP://OU=Accounting,OU=Computers,DC=%Userdomain%,DC=internal")

If @Error = 0

	$objAdsPath.filter = $filter
	For Each $obj In $objAdsPath
		$PcName = SUBSTR($obj.name, 4)
		Shell '"'+%COMSPEC%+'" /c ping -n 1 ' + $PcName + ' |find /C "TTL=" >nul'		
		$OSPing = NOT @ERROR	
		If $OSPing = 1
			$ShellCMD = 'shutdown -s -f -m ' + $PcName + ' -t 300'
			Shell $ShellCMD
			? "shutting down " + $PcName
		Else
			? "computer not online"
		Endif
	Next

Else
	? "Not able to connect to LDAP path."
Endif


However, I don't want any computers that are connected via the VPN to be shutdown. So I want to be able to exclude any computers on IP Address range 192.168.10.

I have managed to find an example of how to output the IP Address of a ping command to a variable, but cannot get this to work in my script. Posted below is the example I found on the Internet. However I need to replace http://www.google.de with + $PcName + as well as convert the code below to kixtart.

What the script should be doing is looking inside [] of the ping reply for the IP Address and outputting it to the variable $IP.

Example Script found on the Internet:

 Code:
for /f "tokens=2 delims=[]" %%a in ('ping -4 -n 1 www.google.de ^|find "["') do set "IP=%%a"
echo %IP%


My kixtart conversion from batch file:

 Code:
For Each
Shell '"'+%COMSPEC%+'" /c ping -n 1 ' + $PcName + ' |find /C  "[=" $IP'
? $IP
Next


My code gives error expected variable! Obviously has to do with "[=" not being correct for Kix to read what is in the bracket [] of the ping reply.