Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
workflow Get-VMIdFromJobId {
    #Get VMM Connection Object
    $vmmcon = Get-AutomationConnection -Name "SCVMM"
    #Construct the VMM Credential
    $securepw = ConvertTo-SecureString -AsPlainText -String $vmmcon.Password -Force
    $VMMMgmtcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $vmmcon.Username, $securepw
    $vmId = InlineScript {
$vmm = Get-SCVMMServer -ComputerName $USING:vmmcon.ComputerName -Credential $USING:VMMMgmtcred
If (!$vmm) { throw "ERROR: connecting to SCVMM Server" }
$vmIdOutput = (Get-SCJob -ID $USING:VMMjobid).ResultObjectID.Guid
return $vmIdOutput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.