Created
May 15, 2023 19:16
-
-
Save NathanTheGr8/0e49048403d95418eec2e59403625b31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Site configuration | |
$SiteCode = "TES" # Site code | |
$ProviderMachineName = "Primary.domain.LOCAL" # SMS Provider machine name | |
# Customizations | |
$initParams = @{} | |
#$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging | |
#$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors | |
# Import the ConfigurationManager.psd1 module | |
if((Get-Module ConfigurationManager) -eq $null) { | |
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams | |
} | |
# Connect to the site's drive if it is not already present | |
if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) { | |
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams | |
} | |
# Set the current location to be the site code. | |
Set-Location "$($SiteCode):\" @initParams | |
$count = 0 | |
$Array = Get-Content "C:\Temp\Collection.txt" | |
$array | foreach { | |
$percent = ($count/($Array.Length))*100 | |
Write-Progress -Activity "adding pcs $count of $($Array.Length)" -PercentComplete $percent | |
Add-CMDeviceCollectionDirectMembershipRule -CollectionName "ProvWave2-Devices" -ResourceID (Get-CMDevice -Name $_).ResourceID | |
$count++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment