Add Machine to a Collection

Here is another simple little script for doing a mass add of Machine Direct rules to a SCCM collection.

Note: You will need to have the console installed on the machine that you run this script from due to the powershell cmdlets required.

Import-Module -Name "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"

$a = Get-Content "i:\temp\temp.txt"

foreach ($i in $a)
    {
    $i | Out-File -FilePath c:\temp\assignout.log -Append
    $device = get-cmdevice -Name $i
    Add-CMDeviceCollectionDirectMembershipRule -CollectionName "Collection Name" -Resource $device | Out-File -FilePath c:\temp\assignout.log -Append

    }

Comments

Popular posts from this blog

Intune Hybrid - NDES Cert Issue

Stuck @ "Waiting for user logon"

Triggering a software update install via Powershell