PowerShell Script to notify you when a server has finished rebooting

I do a lot of server rebooting, especially when I am testing policies etc. Ping doesn’t tell you whether a server is ready to be logged onto and watching a console can be painful so I wrote this small script that will give you a popup on the screen to tell you when a server has finished rebooting and is ready for logon.

The script needs to be run with elevated rights so that it can check the running services on the server.

Disclaimer: Use this script at your own risk. All scripts should be tested on non-Production environments first.

[download id=”1557″]

[download id=”1561″]

[download id=”1559″]

[download id=”1563″]

<# .SYNOPSIS Checks to see if a server has come back from a reboot .DESCRIPTION Checks a rebooting server and then displays a popup once the server is ready for logons .PARAMETER ComputerName The name of the computer that is being rebooted .EXAMPLE PS C:PSScript > Reboot_Checker_V1.ps1 -ServerName MyServer

Will check to see when the server called MyServer has come back from a reboot and display a message on the screen.
.INPUTS
None. You cannot pipe objects to this script.
.OUTPUTS
No objects are output from this script. This script creates a its own logs files
.LINK
http://www.shaunritchie.co.uk
.NOTES
NAME: RebootChecker_V1.ps1
VERSION: 1.00
AUTHOR: Shaun Ritchie
#>

#Thanks to @jeffwouters and @carlwebster for the below parameter structure.

[CmdletBinding(SupportsShouldProcess = $False, ConfirmImpact = “None”, DefaultParameterSetName = “”) ]

Param ([parameter(Mandatory=$True)]
[Alias(“F”)]
[ValidateNotNullOrEmpty()]
[String]$ComputerName=””)

$NetLogon =@()
Start-Sleep -Seconds 90
Do
{
Try
{
Start-Sleep -Seconds 5
$NetLogon = Get-Service -ComputerName $ComputerName | Where-Object {$_.ServiceName -eq “Netlogon”}
}
Catch
{
}
} Until ($NetLogon.Status -eq “Running”)

$wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
$Output = $wshell.Popup(“$ComputerName has finished rebooting”,0,”Reboot”,64+0)