‘##########################################################################
‘# Purpose : To check the ping status of computers part of a security group
‘# Author : Sitaram Pamarthi
‘#
‘##########################################################################
‘On Error Resume Next‘ Replace with your group DN
GroupDN=”ldap://CN=Your/ Group Name,OU=Your OU name,DC=domain,DC=com”Set objGroup = GetObject(GroupDN)
objGroup.GetInfo
arrMemberOf = objGroup.GetEx(“member”)
For Each strMember in arrMemberOf
Set objGroup1 = GetObject(“LDAP://” & strMember)
strHost=trim(objGroup1.dNSHostName)
set objPing = GetObject(“winmgmts:{impersonationLevel=impersonate}”).ExecQuery _
(“select * from Win32_PingStatus where address = ‘” & strHost & “‘”)for each objRetStatus in objPing
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
WScript.Echo strhost & ” ==> host not reachable”
else
Ping = True
wscript.echo strhost & ” ==> Machine Reachable”
end if
next
Next‘#End of script.
Sitaram Pamarthi
Comments on this entry are closed.
Here is the powershell equivalent code for this.
$groupmembers = Get-QADComputer -memberof "domain.com/ou-name/group-name"
foreach ($member in $groupmembers) {
$comp = $member.name
$status = Get-WmiObject win32_Pingstatus -filter "Address = '$comp'"
if($status.statuscode -eq 0) {
write-host -foreground green "$comp(ONLINE)"
}Else {
write-host -foreground red "$comp(OFFLINE)"
}
}
I’m in as long as Canadian’s can participate