SDK and PowerShell
3 TopicsAdminService 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 Invoke-RestMethod -Method Post -Uri "https://<ServerName>/AdminService/wmi/SMS_Collection('<CollectionID>')/AdminService.AddMembershipRule" -Credential $Credentials -Body "{'collectionRule':{'RuleName':'<DeviceName>'}}" -ContentType "application/json" 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 Martin1.8KViews0likes1CommentConfiguration Manager SDK redistributables available on NuGet.org
In addition to the previously published Client Messaging SDK package, we are now making the following Configuration Manager SDK libraries available as packages on NuGet.org. Now you can easily consume them in your own projects and be alerted to updates. Read more about it in the Enterprise Mobility + Security blog.1.3KViews0likes0CommentsUsing REST API to get / set device variables
Hi, I'm trying to set a couple of variables against a machine name, through using the REST API. These are the variables that are set that you can see in the console if you right click properties on a device and go to the 'Variables' tab. These are handy because they can later be referenced during Task Sequences / OSD. I just can't figure out how to do it with the REST API. I have no issues doing it with the powershell module using the 'New-CMDeviceVariable' command, but my solution i'm building at the moment requires the solution to be done with rest api, not with ps modules... I can connect to REST API using powershell using commands such as the below. This all works fine. $ConfigMgrServerURL = "https://SCCMserver.domain.local" $MachineName = "MachineName1" # Following command is a sample GET request, which works. (Invoke-RestMethod -Method Get -Uri "$ConfigMgrServerURL/AdminService/wmi/SMS_R_System?`$filter=Name eq '$MachineName'" -Credential $Credential) #I can also fetch "Custom Properties" via this command (Invoke-RestMethod -Method Get -Uri "$ConfigMgrServerURL/AdminService/v1.0/Device($ResourceID)/AdminService.GetExtensionData" -Credential $Credential) Now i just can't see where i can go to set a variable on the machine. Does anyone have any ideas ? Thanks!32Views0likes0Comments