Create and run scripts with the new feature “Run Powershell scripts from the ConfigMgr console” on current branch 1706

In my last post I talked about how we could activate the new feature “Run Powershell script from the ConfigMgr” on current branch 1706 and in this post I would like to talk about on how to get started using this wonderful feature once you have activated it.

This feature really shows that the ConfigMgr product team over at Microsoft really listens to its community and that they do everything they can to improve the product. Tho this feature is a bit rough around the edges it shows great potential and i can’t wait to see how it will evolve over time and as always if you have any suggestions for improvements to ConfigMgr let the product team know over at


Create a script


First of all we need to create a script and that’s done by going to Software library > Scripts  and then just right click and “Create script” or click on “Create script” over at the top left corner of the screen.




First thing we need to do is to give the script a name and then we can choose if we want to import a script or just write it our self in the script box below and once we are done just follow through with the wizard Next > Next > Close”



3 4


When the script has been created our next step is to approve or deny the script with the status “Waiting for approval

Note, By default a script creator can’t approve their own script and this is a security feature that’s been added in ConfigMgr since running powershell scripts could have huge security implication. However this setting can be turned off under Hierarchy settings. Look for  “Do not allow script authors to approve their own scripts.” in blog post for how to turn on/off


After you clicked on “Approve/Deny” just follow through with the wizard. First you have the chance to look at the script but you will not be able to modify it and the next step is to approve or deny it and add a comment if you want.


5 6 7 8 9


Now to the fun part of actually running the script. At the moment you are not able to run the script directly on a device but instead you need to run it against a Device collection. Go to Device collections and right click on the collection you want to run the script against. In the wizard that pops up select the script you want to run and then follow through with the wizard.


10 11 12


If you go in to “Monitoring > Client Operations” you will find that a new operation has been started




Then if then a few moments after you go in to “Monitoring > Script Status” you should be able to see you script and status here 



Tips for troubleshooting


First of all i recommend that you have the GUID column added under the script status console window




The client downloads the script to be able to run it and it gets located here C:\Windows\CCM\ScriptStore

The name of the script contains the GUID for the script that we can find in the ConfigMgr Console and just compare that to the name of the script to make sure that the script did download.





Over at the Client you will also find a log file for the script C:\Windows\ccm\logs\Scipts.log




Inside the log file you will see information like this




Final words


Something that’s also worth mentioning is that you need to have the permission Runscript assigned if you want to run scripts.

From MS docs

  • To run scripts – Your account must have Run Script permissions for Collections in the Compliance Settings Manager security role.


This to me sounds like it should be there by default but it isn’t. The only Built in role that has that permissions by default is the Full administrator role.






So what you need to do is to either set full administrator to the user who want’s to run the script or create a custom security role and add the Run script permissions.




That’s all for now and I wish y’all happy scripting !


Feel free to leave any comments and questions below,


You can also find me over at and don’t forget to follow me on twitter


Until next time, Cheers !



About the Author:

Timmy Andersson


  1. Madhu August 4, 2017 at 12:42 - Reply

    I think we can use this option rather than CI in configuration Manager.through scripts we can alomost handle everything and deploy that script to collection on which machines we want to re mediate.

    • Timmy Andersson
      Timmy Andersson August 4, 2017 at 12:58 - Reply

      Yes this method gives us more options in the way we want to use powershell on the clients. But it doesn’t replace CI and script remediation because they are used in different scenarios.
      Run script gives us (almost) real time execution towards a client and the script only runs once. While CI’s are reoccurring and not instantly evaluated from the time you deploy it.

      However I also have blog post on how to trigger an CI evaluation on a collection with the help of powershell here:

      I’ll probably do a post on what the difference are and when to use what.

  2. Kyle August 7, 2017 at 14:51 - Reply

    I have created a few scripts that all say exit code 0 but nothing happens on the client.
    Examples Scripts:

    shutdown.exe -r -t 0
    Restart-Computer $env:COMPUTERNAME

    Both show a exit code 0 but nothing happens.

    • Timmy Andersson
      Timmy Andersson August 8, 2017 at 11:30 - Reply

      Does the scripts.log on the client say anything? Or eventvwr?
      Also, what OS are you running on the client ?

  3. Marcus K. September 1, 2017 at 12:02 - Reply

    you can use instead …

    $computername= “.”
    $win32OS = get-wmiobject win32_operatingsystem -computername $computername -EnableAllPrivileges

  4. traceur gps September 6, 2017 at 11:35 - Reply

    j’avais le plaisir de visiter le blog. bonne continuation

  5. Madhu November 7, 2017 at 16:27 - Reply

    It seems we can display the msgbox by using scripts Feature.

    Ex : if(Test-Path -Path C:\Temp\TestScripts.txt -ErrorAction SilentlyContinue)


    [System.Windows.MessageBox]::Show(‘hurray!!! Scripts option is working :)’)

    New-Item C:\Temp\ -Name TestScripts.txt -ItemType File -Force -ErrorAction SilentlyContinue

    In my case [System.Windows.MessageBox]::Show(‘hurray!!! Scripts option is working :)’) this is not executing if file present.

  6. Madhu November 7, 2017 at 16:28 - Reply

    Small typo “: It seems we can’t display the msgbox by using scripts Feature.

  7. Luis December 4, 2017 at 16:28 - Reply

    Anyone else experiencing issues with the script status window being empty? Tried a few times to rerun the script to my collection which is successful but the script status still says “no items found”

  8. […] enable the feature). Also, if you are not familiar with how to use “Run Script”, take a look at this blog post wherewhere Timmy also explains everything step by […]

  9. Mithun January 17, 2018 at 12:13 - Reply

    I am trying to create run script in SCCM 2016(ver 1706) and deploy it to a collection/Machine. Is there any module available to achieve the same using powershell.

  10. Suresh M February 5, 2018 at 14:52 - Reply

    Thanks for the great article.

    Do we have any default report or SQL query to export the script deployment status.

  11. Jon Miller November 1, 2018 at 19:25 - Reply

    Is there any way to automate this process so that the script continues running so long as it remains in this collection? Trying to use this method for a “self-healing” script that will Start-Service on any machines sitting in our “X service in a stopped state” collection.

Leave A Comment