I have a power-shell-script which is called by a batch-file. The batch calls the script after it has set the execution policy to unrestricted. Currently the script does nothing more than writing a log-file, logging that it has been executed.
Now the odd thing:
Scenario 1: I'm logged in, double click the batch-file, the script is immediately executed, log file is written correctly. Everything works as expected.
Scenario 2: I'm not logged in, the batch-file is executed correctly by our UPS, an APC Smart-UPS RT 3000XL with a PCNS-card (I can see the execution time of the batch in a different log), but the power-shell-script is not always executed immediately. Instead I have to wait either exactly 5 or exactly 10 minutes
I doubt that this is a security-issue because sooner or later the script is executed.
Here's the batch:
echo Shutdown Script > c:\PowerChuteNWShutdown\Start.txt C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command get-executionpolicy C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command set-executionpolicy Unrestricted C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c "& 'C:\PowerChuteNWShutdown\lab_shutdown.ps1'" -Verb RunAs
and the script:
$Logfile = "C:\PowerChuteNWSHUTDOWN\Log.txt" Write-Output "Begin lab_shutdown" Out-File $Logfile Get-Date | Out-File $Logfile -append
Has anyone a explanation for this behavior? Thank you in advance