#import correct file
#Uncomment Restart-Computer

$Server_Reboot_Before_Patching = Import-Csv E:\WSUS_Scripts\Files\PENDING-Reboots-10-08-2019.csv | ? { $_.RebootPending -eq "True" } | select computer

$Server_Reboot_Before_Patching.Computer |  % {
    Write-EventLog -LogName System -Source "Powershell-WSUS-Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Remote" -ErrorAction SilentlyContinue
    Invoke-Command $_ -ErrorAction SilentlyContinue {
        New-EventLog -LogName System -Source "Reboot-Before-Patching" -ErrorAction SilentlyContinue
        Write-EventLog -LogName System -Source "Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Invoke" -ErrorAction SilentlyContinue
    }#endInvoke
    Restart-Computer $_ -Force -Verbose
}#end%

 