Forum Discussion
AdminService add/delete rules in collection
Hi I'm trying to add and delete devices from a collection via AdminService on Configuration manager 2203 from PowerShell.
When I try the below command I receive an error
Error:
Invoke-RestMethod : {"error":{"code":"500","message":"An error with description \"Could not get CCollectionRule* from instance\" occurred when
performing MethodExecution operation on WMI class: SMS_Collection."}}
At line:1 char:1
Error log AdminService.log
Management exception caught: Could not get CCollectionRule* from instance
System.Management.ManagementException: Not found
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObject.InvokeMethod(String methodName, ManagementBaseObject inParameters, InvokeMethodOptions options)
at Microsoft.ConfigurationManager.AdminService.ManagementObjectAbstraction.InvokeMethod(String methodName, IManagementBaseObject inParams, InvokeMethodOptions invokeOptions, WindowsIdentity windowsIdentity)
I get the same error if I try to delete a device from a collection.
Anybody able to help ??
Regards Martin
- Michael_VenigerCopper Contributor
Martin_R_Sorensen Hi Martin, you need to specify a proper body for this. Example:
$body =@'
{
"collectionRule":{
"@odata.type" : "#AdminService.SMS_CollectionRuleDirect",
"ResourceClassName": "SMS_R_System",
"ResourceID": 12345678,
"RuleName": "MyMachine"
}
}
'@