I came across a code snippet by Mick Pletcher () that you can add to the end of a compliance item script to kick off the evaluation of a baseline. I took that and added a parameter to it so you can use it as a ConfigMgr Run Script. It look like a lot of code but 90% is just documentation.
Continue reading “ConfigMgr Run Script – Kickoff Compliance Baseline Check”Category: Scripting
ConfigMgr PowerShell Script – Create Collections off Compliance Settings Configuration Items
The script uses Get-CMConfigurationItem cmdlet to get a list of LocalizedDisplayNames of Compliance Setting CIs and then runs a Foreach to create three collections based using the LocalizedDisplayName. Parameters specify the CM Site Code, Limiting Collection collection ID, and the CI Name. It does a check to see if a collection exists beofre creating which is also a self repair feature as a deleted collection will be recreated.
Continue reading “ConfigMgr PowerShell Script – Create Collections off Compliance Settings Configuration Items”ConfigMgr Run Script – Set Service State
As you can tell, many of my script posts occur after something was needed at work and I ended scripting it. This time we needed to alter the startup of a service on a group of systems. I wrote this PowerShell script to set the startup type and status of a specified service. It does require three parameters: service name, startup type desired, and desired status.
Continue reading “ConfigMgr Run Script – Set Service State”ConfigMgr Log Collector Run Script
In most environment I have worked in, I have not had access or easy access to some systems I was expected to troubleshoot ConfigMgr issues on especially servers. I would normally have to ask for someone to send me logs and half the time needed to explain where to find that logs. I wrote a quick ConfigMgr Run Script that I can target against a system or collection and no longer have to ask for logs because the script will get them for me.
Continue reading “ConfigMgr Log Collector Run Script”Using PowerShell to fake converting ConfigMgr IPSubnet to IPRange boundaries
Over the years that I have done work ConfigMgr, there was a back and forth on what type of boundaries to use between IPRange and IPSubnet. I have worked in places that were one or the other as well as mixed. Normally, what was used was determined by the suggestion of a Microsoft PFE. Now, I want to convert my IPSubnet boundaries to IPRange boundaries. Continue reading “Using PowerShell to fake converting ConfigMgr IPSubnet to IPRange boundaries”
VSCode script template with logging
I recently created an alternative version of the script template. This one is for PowerShell scripts and includes additions for the logging that I do both within a log file and Event Viewer. I am including the template and the code to add to VSCode to make it a snippet. I also have the code and snippets for adding the logging within the script. Continue reading “VSCode script template with logging”
Using VSCode snippets to apply your script template
Previously I wrote about the need for standardizing scripts and showed the template that I made. The question is how to easily start your scripts from the template. You can open the template and save it as a new file but I think that is extra work I do not want to do. If your script editor allows for the use of code snippets, things become easier. My editor of choice is Visual Studio Code (VSCode) and I will show you how to create a code snippet for your template. You can use this to easily add repeatable code to your scripts. Again, this is being done with VSCode which is what I recommend as I love the script analyzer that it has as well as the ability to expand its functionality with community created extensions. Continue reading “Using VSCode snippets to apply your script template”