PowerShell Script Template

I recently went to Midwest Management Summit aka MMS (and if you are in the ConfigMan world and don’t go then you are missing out). A few of the sessions I attended were centered around scripting and how to improve things.  One thing that was brought up a few times is having a standard on how your scripts are formatted.  This is important as it helps when viewing the script to understand what it does and doing any work on the script.  With that I developed the following PowerShell template I would like to share. Continue reading “PowerShell Script Template”

Subscribe Now

I have added a subscription form to the sidebar for those that would like to be notified by email when I make a new post.  I may also send out the occasional newsletter or other such email, but I be spamming anyone or giving out your email addresses as I do not want people doing that to me.

Translating error codes to error messages in your ConfigMgr reports.

I was recently working on a set of custom reports on the configuration baseline and configuration item compliance. I noticed some systems failed on a few configuration items so I decided to bring in the ErrorCode info in from the v_CIErrorDetails view.  Unfortunately, as nice as error codes are to have, we don’t know what all of them mean so plain text reason for an error is helpful.  I am going to show you one way to do just that.

Continue reading “Translating error codes to error messages in your ConfigMgr reports.”

Getting IP or subnet to sort correctly in a SQL query

I recently was working a SQL report that listed our SCCM subnet boundaries so that we could start to combine then into larger IP ranges. The issue is that IP addresses and subnets are not sorted properly. In researching a solution, I found a couple but this is the one I like that most. Continue reading “Getting IP or subnet to sort correctly in a SQL query”

SCCM Run Script Examples

One of my favorite, if not my favorite, features of SCCM current branch is the ability to run PowerShell scripts against a system or collection from within the console. You just have to create a new script in the console and, when you run it against a system or collection, the script runs on the system(s) locally. This is a great way to automate some of those routine tasks you may have. Continue reading “SCCM Run Script Examples”

PowerShell Script to Automate Running ContentLibraryCleanup.exe Against All DPs in SCCM Site

This is a rough script that automates the running of the content library cleanup tool available after SCCM Build 1702. The script will connect to a SCCM site to build a list of distribution points to run against. This needs to be ran on the primary site server under account with full admin rights in SCCM. It checks four possible locations for the PS module and the cleanup tool. The script prompts for the SCCM site code, the FQDN of the primary site server, and if you want the tool to delete orphaned content or just log to the tools default log location. Continue reading “PowerShell Script to Automate Running ContentLibraryCleanup.exe Against All DPs in SCCM Site”

PowerShell Script to Look for Installed KB

This is a basic PowerShell script that can be used to determine if a KB related update is installed. You can use it to check and run an uninstall command or as part of a SCCM Compliance Settings configuration item. Yes, you can add updates directly to configuration baselines, but I am still learning PowerShell and wanted to do it the hard way. Plus, you can add additional script to it look at other things besides the presence of a KB to include installed software, state of a service, or registry settings. The compliance can also be switched around where having the KB installed is not complaint and then a remediation script can be used to uninstall the KB. Continue reading “PowerShell Script to Look for Installed KB”