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

Clear
#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 = $strcomputer.name
$PingStatus = Gwmi Win32_PingStatus -Filter “Address = ‘$MachineName'” |

Select-Object StatusCode

if($PingStatus.StatusCode -eq 0)
{
$value = “EnableAdapterDomainNameRegistration”
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(‘LocalMachine’,$strComputer.name)
$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”
$regkeyfull.SetValue($value,1)
$Answeragain = $regkeyfull.GetValue($value)
Write-Host “Is now set to:”$Answeragain -Fore “Green”
“”
}
else
{Write-Host $MachineName ” did not respond to a ping!” -Fore “Red” }
}

Advertisements

Leave a comment

Filed under Active Directry, Powershell

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s