Hi,
i have some scheduled tasks that have run for years without issue, now since upgrading to WMF5 I am getting them fail with code 0x1.
They are setup to run “powershell.exe” with the argument of “-File {FullPathToScript}” and the start in folder is set to the script path.
If I add a Start-Transcript line to the top of the script it runs without issue, but if I remove this I get an error running it.
The script runs fine as that user when run manually and it seems to be something that has changed with WMF5 causing this issue as they had been running fine for years until the server was upgraded to WMF5.
I have some of the scripts working by adding the start-transcript line, but would prefer not to update all my scripts with this.
The server in question is running Windows Server 2012 R2
Any ideas or assistance on this would be greatly received.
8 Spice ups
martinc
(Martin1718)
2
try running your task like this
powershell.exe -NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File \\path\to\script.ps1
Hi Martin,
Thanks for the reply, I have tried with all of those switches and various combinations of them and get the same outcome.
It’s as if something in the script is not valid anymore even though it runs fine if I add a transcript line at the beginning or if i run it manually as a user.
very odd.
martinc
(Martin1718)
4
does the script do anything it’s supposed to?
are you running it with the highest privileges checked?
does your script return a value $true / $false? if not this could cause the issue as well but it will still run
Does the scheduled task run successfully if it is manually run?
If it does not, I would check to make sure that it is configured to run with the highest permissions, and also configured for the corresponding OS. I would also verify the user account which is defined in the scheduled task - as I don’t know what the script may do, but if the account running the script does not have permissions do what the script does, I could see what that would produce a problem.
Almost all of my PowerShell tasks are defined as running PowerShell with a Start in C:\fullpath\toscript with arguments of .\scriptname.ps1 and they have flawlessly for quite some time. ::knocks on wood::