Comments on: Add Multiple Devices to SCCM collection using PowerShell https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/ SCCM | ConfigMgr | Intune | Windows 11 | Azure Wed, 25 Oct 2023 23:52:06 +0000 hourly 1 https://wordpress.org/?v=6.4.1 By: Eli https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-56345 https://www.prajwaldesai.com/?p=216051#comment-56345 In reply to Xiaomeng.

Thank you! Kept getting an error until I added the -Resource 🙂

]]>
By: Adam https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-53558 https://www.prajwaldesai.com/?p=216051#comment-53558 Hey Praj ; I don’t know why this isn’t working exactly. But here’s what i’m getting.

Add-CMUserCollectionDirectMembershipRule : Cannot bind argument to parameter ‘ResourceId’ because it is null.
At line:1 char:129
+ … tionName “Server List” -ResourceID (Get-CMUser -Name $_).ResourceID }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-CMUserCollectionDirectMembershipRule], ParameterBindingValidationE
xception
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.ConfigurationManagement.PowerSh
ell.Cmdlets.Collections.AddUserCollectionDirectMembershipRule

I’m referencing my Server list.txt ; the servers are just listed by name. What am I missing?

]]>
By: Carlos Bta https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-44759 https://www.prajwaldesai.com/?p=216051#comment-44759 anyone get this error:

Add-CMDeviceCollectionDirectMembershipRule : No object corresponds to the specified parameters.
At line:5 char:1
+ Add-CMDeviceCollectionDirectMembershipRule -CollectionName “RY1-Remov …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Confi…tMembershipRule:AddDeviceCollectionDirectMembershipRule) [Add-CMDeviceCol…tMembershipRule], ItemNotFoundException
+ FullyQualifiedErrorId : ItemNotFound,Microsoft.ConfigurationManagement.PowerShell.Cmdlets.Collections.AddDeviceCollectionDirectMembershipRule

please help me.

]]>
By: cogerino mickael https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-42829 https://www.prajwaldesai.com/?p=216051#comment-42829 hello,

when i try to import some users see what i have :

Get-CMDevice : This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive.
At line:1 char:177
+ … odification Profil Chrome” -ResourceID (Get-CMDevice -Name $_).Resour …

+ CategoryInfo : DeviceError: (Microsoft.Confi…tions.GetDevice:GetDevice) [Get-CMDevice], InvalidOperationException
+ FullyQualifiedErrorId : CommandCannotExecuteFromCurrentDrive,Microsoft.ConfigurationManagement.PowerShell.Cmdlets.Collections.GetDevice

i don’t understand because i import the file from the server … can you help me with ?

thanks a lot

]]>
By: Trev Evans https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-42223 https://www.prajwaldesai.com/?p=216051#comment-42223 Heres a little improvement that checks 1st if the resource exists.

Get-Content “D:\Support\source\machines.txt” | foreach {
write-host “Adding: $_”
$device_add = Get-CMDevice -Name $_
if ($device_add ) {
Add-CMDeviceCollectionDirectMembershipRule -CollectionName “My_Collection” -ResourceID (Get-CMDevice -Name $_).ResourceID }
else
{ write-host “$_ dont exist in SCCM”
}
}

]]>
By: Amit Deore https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-40544 https://www.prajwaldesai.com/?p=216051#comment-40544 Thanks Prajwal for sharing the script.
I have successfully used it multiple times in my organization to create device collections in bulk.

Just have one query, once we are done with PowerShell script execution we will be getting the exact device number for collection.
I have observed that there is change (Increase/Decrease) in collection devices after few days, and it keep on increasing and decreasing.
As per my understanding as this collection is Static, the number should not change.

]]>
By: Cong Le https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-36103 https://www.prajwaldesai.com/?p=216051#comment-36103 In reply to mehdi.

Cause the objects are not exist in your directory.

]]>
By: Alexej F. https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-35108 https://www.prajwaldesai.com/?p=216051#comment-35108 In reply to Doe.

Damn, I didn’t even know, that they had this function! Thx a lot

]]>
By: mehdi https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-32697 https://www.prajwaldesai.com/?p=216051#comment-32697 Has anyone gotten this error?
Add-CMDeviceCollectionDirectMembershipRule : Cannot bind argument to parameter ‘ResourceId’ because it is null.
At line:1 char:146
+ … alo Alto 10 percent” -ResourceID (Get-CMDevice -Name $_).ResourceID }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-CMDeviceCol…tMembershipRule], ParameterBindingValidationExceptio
n
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.ConfigurationManagement.PowerSh
ell.Cmdlets.Collections.AddDeviceCollectionDirectMembershipRule

]]>
By: Charita https://www.prajwaldesai.com/add-multiple-devices-to-sccm-collection-using-powershell/#comment-30298 https://www.prajwaldesai.com/?p=216051#comment-30298 Your articles are always useful and easy to understand. Thank you for sharing.

]]>