So I have a tool/script that adds resources to collections using direct
membership rules by using Add-CMDeviceCollectionDirectMembershipRule. Been
using it for quite some time, couple of years at least. Ever since the new
cmdlet library hit, every time I run the script, it complains about "hey
there's a new library!!!!" so to shut that up I installed it. Now, this
cmdlet doesn't seem to work anymore. No matter which way I give it the
collection and the resource, "No object corresponds to the specified
parameters."
For example:
PS AU5:\> $Resource = Get-CMDevice -Name mycomputer
PS AU5:\> $collection = Get-CMCollection -Name mycollection
PS AU5:\> Add-CMDeviceCollectionDirectMembershipRule -Collection $collection
-Resource $Resource
Add-CMDeviceCollectionDirectMembershipRule : No object corresponds to the
specified parameters.
At line:1 char:1
+ Add-CMDeviceCollectionDirectMembershipRule -Collection $collection -Resource
$Re ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:String)
[Add-CMDeviceCol...tMembershipRule], ItemNotFoundException
+ FullyQualifiedErrorId :
SessionStateException,Microsoft.ConfigurationManagement.Cmdlets.Collections.Commands.Add
DeviceCollectionDirectMembershipRuleCommand
Fails with "No object corresponds to the specified parameters." Despite both
$resource and $collection have the correct data in them. OK, so I try:
$Resourceid = (Get-CMDevice -Name mycomputer).resourceid
$collectionid=(Get-CMCollection -Name 'My Collection').collectionid
Add-CMDeviceCollectionDirectMembershipRule -Collectionid $collectionid
-Resourceid $Resourceid
Same thing. "No object corresponds to the specified parameters." So wondering
about the InvalidArgument: (:String) part I look at the help. It says
"Add-CMDeviceCollectionDirectMembershipRule -CollectionId <String> -ResourceId
<Int32>" so I check $collectionid to make sure it's a string and $resourceid to
make sure it's an integer. They are. So I finally try to just type it out
PS AU5:\> Add-CMDeviceCollectionDirectMembershipRule -CollectionId 'AU50024A'
-ResourceId 16784543
Add-CMDeviceCollectionDirectMembershipRule : No object corresponds to the
specified parameters.
At line:1 char:1
+ Add-CMDeviceCollectionDirectMembershipRule -CollectionId 'AU50024A'
-ResourceId 16 ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:String)
[Add-CMDeviceCol...tMembershipRule], ItemNotFoundException
+ FullyQualifiedErrorId :
SessionStateException,Microsoft.ConfigurationManagement.Cmdlets.Collections.Commands.Add
DeviceCollectionDirectMembershipRuleCommand
and same result. "No object corresponds to the specified parameters."
InvalidArgument: (:String)
Anybody seen this or know what else I can do?
Todd