$primarysiteserver = "SERVER"
$primarysitecode = 'XXX'
$DPS = ""
$DPS = Get-WmiObject -ComputerName $primarysiteserver -Namespace ROOT\SMS\site_$primarysitecode -Query "select * from SMS_DistributionPointInfo" | where {$_.ispxe -eq $true} | select -expandproperty name
$count = 0
foreach ($DP in $DPS) {
$count++
$online = Test-Connection -count 1 -ComputerName $DP -quiet
if ($online -eq $true) {
write-host "($count)" $DP "is now rebooting" -ForegroundColor Green
Restart-Computer -ComputerName $DP -force
} else {
write-host "($count)" $DP "is offline" -ForegroundColor Red
}
}