Powershell Workflow Restart-Wait Not working

I’m attempting to run this on a remote computer and the restart wait isn’t working

The code is below. It should work even though it’s running on the local machine when I invoke the workflow on it.

$computerName = "" $session = New-PSSession -ComputerName $computerName $todaysDate = get-date $filename = "$hostname_$todaysDate_PrePatchServices" Invoke-Command -session $session -ScriptBlock { workflow patch-client { sequence { Get-Service | Out-File "C:statuscodes$filename.txt" Restart-Computer -wait -PSComputerName $computerName -Force Out-File C:statusCodesreboot1.txt Restart-Computer -wait -Force out-file C:statusCodesreboot2.txt } } patch-client } 

It rushes through the script and finishes everything and throws an error about it not being able to restart because one is in progress, so it’s not waiting. What am I doing incorrectly?

submitted by /u/sanwil9
[link] [comments]

Leave a Reply