This repository has been archived on 2020-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
control-ad/scripts/computers/restart-computer.ps1

31 lines
751 B
PowerShell

function Restart-Domain-Computer
{
try
{
$computername = Read-Host 'Please enter a computer name'
Restart-Computer -Force -ComputerName $computername -ErrorAction Stop
sleep 30
while ($status -eq $null)
{
if(Test-Connection -Computername $computername `
-BufferSize 16 `
-Count 1 `
-Quiet){break}
Write-Host 'Still offline'
sleep 5
}
Write-Host
Write-Host -backgroundcolor "green" $computername ' is online'
Write-Host
Read-Host 'Press a key to quit'
}
catch
{
Write-Warning $_
Read-Host 'Press a key to quit'
break
}
}
Restart-Domain-Computer