On the site server, that’s R2 SP1 no CU, with the older library I get this:

PS C:\Users\us-moter> cd au5:
PS AU5:\> $Resource = Get-CMDevice -Name esm-win-t01
WARNING: An update to the System Center 2012 Configuration Manager Cmdlet 
Library is available. Please go to
'http://go.microsoft.com/fwlink/?LinkId=528947' to download the latest version. 
Running cmdlet version: 5.0.8231.1004
Latest cmdlet version: 5.0.8249.1128
PS AU5:\> $collection = Get-CMCollection -Name 'MW - Every Monday 1800-2200'
WARNING: An update to the System Center 2012 Configuration Manager Cmdlet 
Library is available. Please go to
'http://go.microsoft.com/fwlink/?LinkId=528947' to download the latest version. 
Running cmdlet version: 5.0.8231.1004
Latest cmdlet version: 5.0.8249.1128
PS AU5:\> Add-CMDeviceCollectionDirectMembershipRule -Collection $collection 
-Resource $Resource
WARNING: An update to the System Center 2012 Configuration Manager Cmdlet 
Library is available. Please go to
'http://go.microsoft.com/fwlink/?LinkId=528947' to download the latest version. 
Running cmdlet version: 5.0.8231.1004
Latest cmdlet version: 5.0.8249.1128

No errors.

On a server with the 5.00.7958.1000 SCCM console version it works but complains 
about get-cmcollection not existing, so I changed it to get-cmdevicecollection 
and it worked no errors.

PS D:\Scripts> cd au5:
PS AU5:\> $Resource = Get-CMDevice -Name esm-win-t01
PS AU5:\> $collection = Get-CMCollection -Name 'MW - Every Monday 1800-2200'
Get-CMCollection : The term 'Get-CMCollection' is not recognized as the name of 
a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try
again.
At line:1 char:15
+ $collection = Get-CMCollection -Name 'MW - Every Monday 1800-2200'
+               ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-CMCollection:String) [], 
CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS AU5:\> $collection = Get-CMDeviceCollection -Name 'MW - Every Monday 
1800-2200'
PS AU5:\> Add-CMDeviceCollectionDirectMembershipRule -Collection $collection 
-Resource $Resource

Only on the server with cmdlet library 5.00.8249.1128 do I get this.  So it 
seems to be an issue between SCCM R2 SP1 and the new library.

Todd

From: [email protected] [mailto:[email protected]] On 
Behalf Of Mote, Todd
Sent: Wednesday, September 23, 2015 10:54 AM
To: '[email protected]' <[email protected]>
Subject: RE: [mssms] New cmdlet library for configmgr

CM 2012 R2 SP1 no CU (5.0.8239.1000), cmdlet library 5.00.8249.1128.

:/



From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Sean Pomeroy
Sent: Wednesday, September 23, 2015 10:44 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: [mssms] New cmdlet library for configmgr

Strange. I used you first example and it worked fine.

What version of CM are you one?
What version of the library is installed?

I am on CM 2012 R2 RTM with cmdlet library 5.00.8249.1128




On Wed, Sep 23, 2015 at 11:26 AM Mote, Todd 
<[email protected]<mailto:[email protected]>> wrote:

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




Reply via email to