Device Variables and SCCM/Orchestrator

Forum: Config Manager
Viewing 1 post (of 1 total)
  • #230333
    Profile photo of stmacphe

    Hi All,

    I hope this is the right forum.

    I’m building servers using Orchestrator to create a “bare metal” VM, add the device object to SCCM, add a number of variables to the device object (domain,IP vlan,cluster etc) and finally start the VM to PXE Boot. That calls SCCM OSD Task Sequence to add the OS, VM Tools and other stuff – and that works well. What I then need to do is have the Task Sequence call a second Runbook that will Re-IP the server and move it from our build VLAN/Cluster to it’s final destination. Each stage works fine on it’s own, however I cant get the Task Sequence to pass the device variables I added back to the second Runbook – is this even possible? I know you can pass built in variables.

    So I decided to try something else and just pass the built in variable “_SMSTSMachineName” to the 2nd runbook. This worked however now I need to get the device variables from SCCM using powershell from my Orchestrator Runbook. This I did and the script works in testing but doest work when called from SCCM – “This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive.”

    This is the script. I know there is something about SCCM using powershell 32bit – Could that be the issue?

    Any guidance appreciated. Thanks

    #Script – Get the VM variables from SCCM rewuired to complete this Runbook

    $VMName = “D2StuTest106”
    $SCCMServer = “d2wvsccpspe01.slc.internal”
    $nl = [Environment]::NewLine
    $tab = “t” #tab
    Import-Module “C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1”
    New-PSDrive -Name SLC -PSProvider CMSite -Root $SCCMServer
    CD SLC:

    $Verify = Get-CMDevice -Name $VMName

    #Check that a VM name has been supplied
    $VMNum = $VMName | measure
    If ([string]::IsNullOrEmpty($VMName) -or $VMNum.Count -ne 1) {
    $Output1 = “VM name not supplied”
    #Verify VM exists in SCCM
    ElseIf (-Not $Verify) {
    $Output2 = “$VMName not found in SCCM”
    Else {
    $Results = Get-CMDeviceVariable -DeviceName $VMName
    $Output3 = “No Variables found for $VMName”
    Else {
    forEach($Variable in $Results){

    switch ($Variable.Name) {
    “IPAddress” {$IPAddress = ($Variable.Value -replace”t|n|
    “VLAN” {$VLAN = ($Variable.value -replace”t|n|r”,””)}
    “Datacenter” {$Datacenter = ($Variable.Value -replace”t|n|
    “Cluster” {$Cluster = ($Variable.Value -replace”t|n|r”,””)}
    “BuildDomain” {$ADDomain = ($Variable.Value -replace”t|n|

    cd c:
    Remove-PSDrive -Name SLC -Confirm:$false

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.