Search code examples
powershellsccm

PowerShell call SCCM object variable


How does one call SCCM Object variables in PowerShell?

Lets say I have a collection variable on SCCM Objects called "ABC_RegionCode" and it has a different value on every machine in the collection.

How would i call this in Powershell?

$RegionCode = "ABC_RegionCode" will just give me the aforementioned string.


Solution

  • Ordinarily I'd suggest getting this straight from the database, but it's stored encrypted in v_CollectionVariable. If you're on 2012 you can try using Get-CMDeviceCollectionVariable (https://technet.microsoft.com/en-us/library/jj821935%28v=sc.20%29.aspx).

    So you'd call something like:

    $RegionCode = (Get-CMDeviceCollectionVariable -CollectionID "SMS00001" -VariableName "ABC_RegionCode").Value