I am having an issue with a Function I am calling in a startup script on Server 2008 R2. The function runs the Register-ScheduledJob cmdlet, which in turn creates a task that schedules the running of the Disk Cleanup Tool monthly on the user’s local disk.
I am struggling because I have tried to apply basic troubleshooting (I am still raw with Powershell), so have run from the PS console each line within the function. I have executed the function manually, I have created a Start-Job cmdlet that runs the Powershell script from within the console. All these steps cause the Scheduled Job to be created. However it does not appear to run when applying Group Policy on startup.
There is nothing wrong with the GPO, since I had other PS Scripts inside, including one that wrote to the HKLM: Branch in the registry…My understanding is that the script on startup runs as the SYSTEM Account, as I type this I am thinking is it because it would need to save the xml in the ScheduledJob folder in the SYSTEM Profile which does not exist. Am I therefore needing to offer it alternate credentials…any advice would be much appreciated.