This is on Windows 2012 Server Datacenter
Have a windows task setup to run under a specific domain account.
Security options = Run whether the user is logged on or not and "run with highest privileges" checked. This account is also a local admin.
The task executes a powershell script that works fine when I invoke it manually
The task has 3 actions and are listed here:
Start a program powershell Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force
Start a program powersehll .\myscript.ps1
Start a program powershell Set-ExecutionPolicy -ExecutionPolicy Restricted
This seemed to work fine when I setup this same task on another machine, as well as my own workstation. However, on this particular server, I get errors in the windows event log in pairs. One is an explicit entry that Im writing to the event log from within the powershell script within a try/catch, but the other is an error with EventID 1511 from the User Profile Service. "Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off."
The other error that I am logging is due to the webrequest, and its getting a http 401 error.
This account was setup as a domain service account. What could be causing this issue with the user profile? I suspect that since our domain controller is still on 2008, this might be related?
Invoke-WebRequest
processes I setup for a company for automation I use format such asInvoke-WebRequest -Uri $url -TimeoutSec 300
and I put that within a TRY CATCH block to do something different on error exception. Increase theTimeoutSec
. The domain is 2008 DCs there too btw.HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
location.Program/script
andAdd arguments (optional)
fields. Another thing that's easy enough to try... Point to the full explicit path to the PS1 file and the PowerShell.exe executable.