Script - Add Collection to Collections - V

This is a simple script that will add a Collection to a group of other Collections based on a filter.
Adds a Colelction to another Collection

The Script will add a specified Collection to either a Collection or a group of filtered Collections

Filters the SCCM collections the collection is added to

Specifyes the Site Server to connect to

Specifies the Site Code of the SCCM enviroment

Tells the script to load the SCCM Module from the local computer or the server 

Add-Collection.ps1 -CollectionToAdd "All Desktops" -Filter "Install - Available*" -LoadLocal -SiteServer "SRV-SCCM" -SiteCode "STI"
Adds the All Desktops colelction to the all collectiosn that start with Install - Avaialbe 

Created By: Kris Gross
Twitter: @kmgamd
Script Version:




if ($LoadLocal -eq "$True") 
        Set-Location 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\'
        Import-Module .\ConfigurationManager.psd1 -verbose:$false   
        Import-Module \\$SiteServer\SMS_$SiteCode\AdminConsole\bin\ConfigurationManager.psd1 -verbose:$false

$site = $SiteCode + ":"
Set-Location $site

$CollectionFilter = (Get-CMDeviceCollection | Where-Object Name -Like "$Filter").name

ForEach ($Collection in ($CollectionFilter))
    Add-CMDeviceCollectionIncludeMembershipRule -CollectionName "$Collection" -IncludeCollectionName "$CollectionToAdd"

set-Location $PSScriptRoot


Popular posts from this blog

SCCM Task Sequence GUI - How to set up the TS to work with a GUI

SCCM Applications vs. SCCM Packages: Understanding the Key Differences

How to Deploy a Windows 10 Servicing update as a Application