Powershell error when running Register-ScheduledJob command

1

When running the command Register-ScheduledJob with even the most basic parameters, for example

Register-ScheduledJob -ScriptBlock {Get-Process} -Name Testing

I receive the following error:

writeErrorStream      : True
PSMessageDetails      : 
Exception             : System.Management.Automation.RuntimeException: A directory not found 
                        error occurred while registering scheduled job definition testing.  
                        Make sure you are running Windows PowerShell with elevated privileges. 
                        ---> Microsoft.PowerShell.ScheduledJob.ScheduledJobException: An error 
                        occurred while registering scheduled job definition testing to the 
                        Windows Task Scheduler.  The Task Scheduler error is: The system cannot 
                        find the path specified. (Exception from HRESULT: 0x80070003). ---> 
                        System.IO.DirectoryNotFoundException: The system cannot find the path 
                        specified. (Exception from HRESULT: 0x80070003)
                           at TaskScheduler.ITaskService.GetFolder(String Path)
                           at Microsoft.PowerShell.ScheduledJob.ScheduledJobWTS.GetRootFolder()
                           at 
                        Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition.AddToWTS()
                           at 
                        Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition.Register()
                           --- End of inner exception stack trace ---
                           at 
                        Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition.Register()
                           at Microsoft.PowerShell.ScheduledJob.RegisterScheduledJobCommand.Proc
                        essRecord()
                           --- End of inner exception stack trace ---
TargetObject          : Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition
CategoryInfo          : ObjectNotFound: 
                        (Microsoft.Power...edJobDefinition:ScheduledJobDefinition) 
                        [Register-ScheduledJob], RuntimeException
FullyQualifiedErrorId : DirectoryNotFoundWhenRegisteringScheduledJobDefinition,Microsoft.PowerSh
                        ell.ScheduledJob.RegisterScheduledJobCommand
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

What I've done:

  1. Confirmed that I am running PowerShell as an administrator
  2. Tried executing the command Register-ScheduledJob from 32-bit, 64-bit, and ISE
  3. Confirmed the directory $home\appdata\local\Microsoft\Windows\PowerShell\ScheduledJobs does exist

I am running this from a fairly locked down environment. My guess is that there is a security policy that is stopping me from creating jobs from PowerShell

powershell
asked on Stack Overflow May 19, 2016 by Luke Pafford

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0