How to trigger [Run Script] for a SCCM Device with PowerShell?

Stefan Horz 3,466 Reputation points
2020-09-15T08:57:18.127+00:00

Hello,
is it possible to trigger "Run Script" in Endpoint Configuration Manager on a Device with PowerShell? Any example with Invoke-WMIObject available?
24838-how-to-automate-sccm-run-script.jpg

Regards,
Stefan

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Other
0 comments No comments
{count} votes

Accepted answer
  1. Stefan Horz 3,466 Reputation points
    2020-09-15T14:41:55.023+00:00

    Hi,
    it can be automated with Invoke-CMScript from the Configuration Manager cmdlets:

    $ScriptObj = Get-CMScript -ScriptName 'Script-Name' -Fast #-Id "DF8E7546-FD66-4A3D-A129-53AF5AA54F80"
    $Device = Get-CMDevice -Name 'DeviceName'
    Invoke-CMScript -InputObject $ScriptObj -Device $Device 
    

    Regards,
    Stefan

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. nam pam 1 Reputation point
    2020-12-08T14:06:51.747+00:00

    46229-image.png

    Hey, is there a way to get the invoke-script result ?

    0 comments No comments

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.