;=================================================================
; 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