Check if a Workstation is alive and set a registry key.

#requires the Quest Active Roles CMDlets or to use the Administrative CMDlets in Win7 change get-QAD to get-AD

$value = “EnableAdapterDomainNameRegistration”

$PingMachines = Get-QADComputer |where {$_.Name -like “*ws”}
# this is only a valid criteria because of this domain’s naming convention

foreach($strcomputer in $PingMachines)
{$MachineName = $
$PingStatus = Gwmi Win32_PingStatus -Filter “Address = ‘$MachineName'” |

Select-Object StatusCode

if($PingStatus.StatusCode -eq 0)
$value = “EnableAdapterDomainNameRegistration”
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’,$
$regKey= $reg.OpenSubKey(“SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\DNSRegisteredAdapters” )
$AdapterID = $regkey.Getsubkeynames()

$regKeyFull= $reg.OpenSubKey(“SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces\\” + $AdapterID, $true )
Write-Host $MachineName -Fore “Green”
$Answer = $regkeyfull.GetValue($value)
Write-Host “Was set to: “$Answer -Fore “Yellow”
$Answeragain = $regkeyfull.GetValue($value)
Write-Host “Is now set to:”$Answeragain -Fore “Green”
{Write-Host $MachineName ” did not respond to a ping!” -Fore “Red” }


Leave a comment

Filed under Active Directry, Powershell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s