Yellow Corporate LinkedIn Banner

Optimizing Incremental Updates on SCCM Collections via PowerShell



Author: Nawaz Kazi

Introduction: The Significance of Incremental Updates in SCCM

In the evolving landscape of system management, ensuring timely and efficient updates is of paramount importance. Incremental updates in SCCM play a crucial role in this regard. These updates allow SCCM to periodically scan for changes, ensuring that the collections are always up-to-date with the latest membership. However, as emphasized by Microsoft’s best practices for collections, it’s not just about enabling incremental updates; it’s about managing them efficiently. Overutilizing this feature without proper management can strain your infrastructure, leading to performance issues. Therefore, striking the right balance is key.

This blog post is a continuation of our previous article where we delved into deleting SCCM collections using PowerShell. Today, we shift our focus to managing the incremental updates of these collections, ensuring they remain optimized and effective.

Now, with the stage set on the importance of incremental updates, let’s dive into the heart of SCCM and PowerShell automation.

Setting the Stage: Preliminary Steps

Before diving into the main script, it’s essential to understand the foundational steps:

Import-Module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1')

Here, we’re dynamically importing the ConfigurationManager module. This module provides the necessary cmdlets to interact with SCCM via PowerShell.

Determining the Site Code: Finding Your Ground

Every SCCM setup has a unique site code. It’s like an address for your specific SCCM instance.

$siteCode = (Get-WmiObject -Namespace "root\SMS" -Class SMS_ProviderLocation).SiteCode
Set-Location $siteCode":"

These lines fetch the site code dynamically and then navigate to the SCCM site directory, ensuring that subsequent commands operate within the right context.

Reading Input: The Starting Point

The core of our script focuses on the collections we aim to oversee. We source these from a CSV file. Ensure the header for the collection ID in the .csv file is labeled as “CollectionID”, added sample file at GitHub

$csvPath = "path_to_your_csv_file.csv"
$collectionIDs = Import-Csv -Path $csvPath | ForEach-Object { $_.CollectionID }

Replace “path_to_your_csv_file.csv” with the path to your CSV file.

The Core Loop: Managing Collections

Now, let’s dive into the core logic:

foreach ($collectionID in $collectionIDs) {
    Get-CMDeviceCollection -CollectionId $collectionID | Set-CMDeviceCollection -RefreshType 2

For each collection ID from the CSV, we fetch the specific collection and set its RefreshType to 2. This action disables its incremental updates but keeps scheduled updates active, ensuring collections remain updated on a regular schedule without frequent disruptions.

If RefreshType is set to1 then incremental and scheduled updates are both disabled, use them as per your need.

Visualization: Seeing the Results in Excel

Rather than merely printing results to the console, our script showcases its output in a dynamically generated Excel sheet:

# Create a new Excel application instance
$excel = New-Object -ComObject Excel.Application

This interactive Excel pop-up provides a clear and intuitive way to view the status of processed collections.

The full script and sample file is on the GitHub repo



Conclusion: Embracing the Power of Optimization

As we wrap up this journey into the intricacies of SCCM collection management, it’s evident that the combination of SCCM and PowerShell is both powerful and invaluable. By optimizing incremental updates, we not only ensure the timely reflection of changes but also maintain the health and performance of our infrastructure. Armed with the knowledge from this guide, you’re now self-assured to harness the best of both worlds, striking a balance between efficiency and effectiveness. Remember, in the realm of system management, staying updated is not just about frequency but also about precision and optimization. Until our next deep dive, keep scripting, keep optimizing, and above all, keep learning.

Leave a Comment

Your email address will not be published. Required fields are marked *