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”
Category: PowerShell
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”
SCCM Compliance Settings Scripts to Alter Service State
Previously I showed how I used SCCM Compliance Settings and Boundary Groups to apply BITS settings. This time I have a discovery and remediation script that can be used with enforce a specific state on a service. If you want to make sure a client’s App-V service stays up or Windows Defender is disabled because you are using another security suite, this could be of help. The script uses variables so someone could easily set the state of the service and start type to what they want. Continue reading “SCCM Compliance Settings Scripts to Alter Service State”