MECM - Get DeviceResourceID in a Task Sequence

Love Arvidsson 116 Reputation points
2021-12-02T13:47:34.28+00:00

Hi!

Is it possible to retrive the DeviceResourceID which you would get with eg. "(Get-CMDevice -Name $Device).ResourceID", in an running Task Sequence, without the need to load MECM PSModule or something like that?

I've looked through the TS Variables, but it doesnt seem to be in any of those, the PS cmdlet wont work without the module, and to get device details using the AdminService, i need to use the ResourceID.

Anyone got any ideas?

Thanks!
Best regards,

Microsoft Security Intune Configuration Manager Deployment
Microsoft Security Intune Configuration Manager Other
0 comments No comments
{count} votes

Accepted answer
  1. Love Arvidsson 116 Reputation points
    2021-12-02T15:08:30.48+00:00

    nvm, figured it out, leaving it here for anyone else to see:

    using "Run PowerShell" script to call the RESTAPI:

    Use TSEnvironment or Powershell to get Devicename, then:

    $DeviceName = "Test01"
    $URL = "https://SITESERVER/AdminService/v1.0/Device?$filter=startswith(Name,'$Device')"
    $DeviceInf = Invoke-RestMethod -Method 'GET' -Uri $URL -Credential $Credentials
    $DeviceResourceID = $DeviceInf.value | select -ExpandProperty MachineId


1 additional answer

Sort by: Most helpful
  1. Jason Sandys 31,406 Reputation points Microsoft Employee Moderator
    2021-12-06T16:34:02.733+00:00

    I would never consider embedding the credentials in task sequence variables as there is no explicit guarantee of their security

    What's the use case here where you want or need the Resource ID of the local system (in a task sequence or otherwise)?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.