Powershell script to remove Scheduled Task fails when deployed but works on the local device

Comments

5 comments

  • James D

    Are you calling a PS1 file or is the script input directly into PDQ? If the script is directly in PDQ, does it run if you reference a script file instead?

    0
    Comment actions Permalink
  • Brad Barfoot

    I have tried both methods.. imbedding the command directly in the Powershell step window, and created a .ps1 script in my Repository and pointed the PS step to it using the Insert PowerShell Script option. Note I have also tried " " and ' ' and "' '" around the task name to to avail. the task is on the root of the scheduler library, so no need to specify the path.

    1
    Comment actions Permalink
  • James D

    Just realized you have a typo in Update. Can you see if that's the issue?

    0
    Comment actions Permalink
  • Brad Barfoot

    Nope, corrected that and still the same error output:

    Unregister-ScheduledTask : No MSFT_ScheduledTask objects found with property 'TaskName' equal to 'MPI Update'.  Verify 
    the value of the property and retry.
    At C:\WINDOWS\AdminArsenal\PDQDeployRunner\service-1\exec\user.ps1:1 char:1
    + Unregister-ScheduledTask -Taskname "MPI Update" -Confirm:$false
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (MPI Update:String) [Unregister-ScheduledTask], CimJobException
        + FullyQualifiedErrorId : CmdletizationQuery_NotFound_TaskName,Unregister-ScheduledTask
     

    0
    Comment actions Permalink
  • James D

    I made a task called "MPI Update" and was able to run your command over Inventory and Deploy and both worked. Can you find the task over PDQ? Maybe you can get the task and pipe it into unregister. 

    Get-ScheduledTask -TaskName "*MPI*" | Unregister-ScheduledTask -Confirm:$false

    1
    Comment actions Permalink

Please sign in to leave a comment.