How to update Scheduled tasks (CimInstanceProperties)?

Petri X 41 Reputation points
2021-08-27T18:27:53.227+00:00

Hi,
I have several servers/workstation collecting user defined Data Collector sets. But unfortunately Microsoft has carried a bug with multiple windows versions, as they state on here: User Defined DCS Doesnt Run As Scheduled

The workaround is to update the Actions on the task as they are guidelines later on that page.

Of course I do not want to do this manually as I have multiple machines to get fixed. So I tried to get it fixed by PowerShell, but I got only grey hairs, not the solution.

I found the place using to get fixed:

$taskActions = (Get-ScheduledTask -TaskName myTaskToBeModified).CimInstanceProperties | Where-Object {$_.name -eq "Actions" }  
$taskActions.Value  

But then I end to the road block.

Has anybody been working around this and could share some thoughts how to get further.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,517 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 33,471 Reputation points
    2021-08-28T13:26:26.477+00:00

    I have not encountered that problem but based on that web page here is something that you can try. I defined a DCS named Perftest, and used this script to update the actions of the task. The task was updated, but I don't know if it's going to work or not.

    $Task = Get-ScheduledTask -TaskName Perftest
    $taskAction = New-ScheduledTaskAction  -Execute 'C:\windows\system32\rundll32.exe'  -Argument 'C:\windows\system32\pla.dll,PlaHost "{Name}" "$(Arg0)"'
    $Task.Actions = $taskAction
    $Task | Set-ScheduledTask
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.