Forum Discussion
Using 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!