Created
January 24, 2017 21:08
-
-
Save bentaylorwork/3b1e2a4318f010bcceddb77a962f6bde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workflow Get-VMIdFromJobId { | |
param( | |
[Parameter(Mandatory=$true)] | |
[STRING]$VMMJobId | |
) | |
#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 | |
} | |
$vmId | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment