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…
Category: PowerShell
Posts pertaining to PowerShell scripting
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…
Scripted ID of Remnant Objects in SCCM for Cleanup
Oftentimes, you will find that MECM (SCCM) will get cluttered over time. Forgotten objects that are no longer deployed will begin to pile up. In the name of good housekeeping, one may periodically wish to search for remnant objects that are no longer deployed. I have recently taken on this task, and I found Matt…
Nuances of Referencing Environment Variables from PowerShell
If you are installing an app such as a database client, you may encounter the need to reference environment variables. There are times where it is absolutely beneficial to do this from within a Powershell script rather than a batch file, and it may simply be that you want to manage other parts of your…
Bypass Deferred Restart For Urgent Powershell Application Deployment via MECM
If a reboot is required for an application installation, you should likely attempt to force the device to reboot using the, “Should Configuration Manager enforce specific behavior regardless of the application’s intended behavior” drop-down menu in the Deployment Type settings. Unfortunately, depending on client settings, you may experience a deferred restart. If you are keen…