Creating or modifying registry keys in PowerShell is a task that comes up frequently when working with Windows. I’ve put together a function that will check for and create a registry key if it does not exist. Just specify the key path, name, and value. As you can see in the first execution, the script…
Category: PowerShell
Posts pertaining to PowerShell scripting
PowerShell – Report CM Application Information
A common problem with applications in Configuration Manager is that an uninstall command has not been specified for many applications. This tends to cause the accumulation of technical debt. As applications age, it will eventually become desirable to remove them from the environment en masse. The ideal time to specify an uninstall command is when…
PowerShell – Ultimate Oracle Client Deinstaller
I’ve put together a PowerShell deinstall script for Oracle clients that I’m dubbing the Ultimate Oracle Client Deinstaller. This deinstall script clears relevant environment variables and creates a .RSP file using Oracle’s deinstall.bat utility. It then deinstalls the Oracle client and cleans up the registry. But wait, there’s more! This script is compatible with Oracle…
PowerShell – Set AD Security Group Membership
Here’s a script that I wrote to allow you to provide a list of machine names and set the membership of an Active Directory security group. It outputs the initial membership count to the console, removes devices that are not present in the provided list, adds devices that are not already present, and then outputs…
PowerShell- Clearing Nullified Environment Variables
I have posted before on the nuances of handling environment variables with PowerShell. I recently encountered an issue where I found a shortcoming of some of my previous scripting work. I was unable to clear nullified environment variables in my current session. I can’t take credit for the script I pieced together to accomplish this,…
Generate Email List From CM Primary User Data
Let’s say you want to perform an ad-hoc test deployment. You build a small test collection and go to deploy, but wait – you ought to do your due diligence and notify the primary users of the targeted devices, right? You highlight primary user data in the console and attempt to copy it to a…
Parallel vs. Serial Execution – Improving PowerShell Script Performance
If you often use scripts utilizing Foreach loops, you’re going to want to read this. Serial execution of this sort of loop is commonplace. But, did you know, by utilizing workflows, you can execute a Foreach loop in parallel? By doing so, we can drastically reduce the execution time of a script because each item…
WQL Query Optimization & Collection Evaluation Run Time
As an engineer working with CM, it is likely you will find yourself running SQL reports to identify collections that may potentially be utilizing sub-optimal query-based membership rules. If these queries have been poorly written, it can waste valuable system resources. If you modify and optimize these queries, it would behoove you to validate (and…
Scripted Restart of Service – Azure Update Management
If you are using Update Management to handle patching of Windows VMs in Azure, you are bound to see devices display in the “Not Assessed” compliance state from time to time. To remedy this, one can restart the service “Microsoft Monitoring Agent (HealthService).” This service has a corresponding process as well, and I check the…
Querying Systems for Specific Hotfix – Patching Pro Tips
Let’s say you’re patching Windows devices, and you install a cumulative update. But, while evaluating patching success, you find there is a required hotfix that was not made available to your devices until after the pending reboot is complete and the cumulative update applied. Now, you need a quick, convenient way to query a list…