Taking advantage of Run Script in ConfigMgr 1710

As most of you already know, Microsoft has released a new function in ConfigMgr to run scripts directly on computers and/or servers in your environment. With this new function, scripts can be run in real time on a single computer or an entire collection. How cool is that?
This was initially released in the 1706 Tech Preview, but since then Microsoft has put a lot of effort into the functionality of the latest builds and have really made it shine!

If you’re like me, you might get stuck in the “this is awesome but how do I move forward with it” mindset. With this new feature, I felt kind of stuck and in need of inspiration. I was lucky enough to find a blog post from Jörgen Nilsson (ccmexec.com – check it out, this guy is really good!) where he used Run Script on client computers to gather ConfigMgr log files, and put them on a share. Perfect!

After some thinking, his specific solution didn’t quite suit my needs as I also wanted the client event logs, and I wanted it more “categorized” on a server share.
Using Jörgen’s post as a foundation, I modified the code to fetch the event logs and also to name the folder with a computer name and date. One thing I had to keep in mind is the script output as I wanted to keep the ConfigMgr console script output clean and neat.  To achieve this, I have piped a lot of the cmdlets to “Out-Null”.

If you do not know how to enable the Run Script feature, I would definitely recommend you check out this blog post from my fellow colleague, Timmy Andersson (where he demonstrates how to 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 step.

Anyways, let’s get to it!

 

After running the script, you can see that the log files has successfully been uploaded to the share.

 

Feel free to use this as you’d like, make modifications and share it with everyone!

Again, check out Timmy’s blogs! He can be reached at https://timmyit.com and here at blog.ctglobalservices.com.
And a BIG thanks to Jörgen Nilsson aka ccmexec.com. This guy is brilliant!

Thank you for reading. Until next time.

And of course – Merry Christmas!

By | 2017-12-20T09:12:22+00:00 December 20th, 2017|Powershell|1 Comment

About the Author:

Stian Myhre Olsen
Configuration Manager and Automation <3

One Comment

  1. Jonathan December 20, 2017 at 22:20 - Reply

    Didnt understand anything, and now my computer is on fire. 10/10, would read again.

Leave A Comment