33$MYINV = $MyInvocation
44$SCRIPTDIR = split-path $MYINV.MyCommand.Path
55
6+ Write-Output " SCRIPT DIR: $ ( $SCRIPTDIR ) "
7+
68. .\variables.ps1
79. ${SCRIPTDIR} \upi- functions.ps1
810
@@ -14,6 +16,7 @@ $Env:GOVC_INSECURE = 1
1416
1517# Connect to vCenter
1618Connect-VIServer - Server $vcenter - Credential (Import-Clixml $vcentercredpath )
19+ $cliContext = Get-PowerCLIContext
1720
1821if ($downloadInstaller ) {
1922 Write-Output " Downloading the most recent $ ( $version ) installer"
@@ -186,14 +189,14 @@ foreach ($fd in $fds)
186189 $ovfConfig.NetworkMapping.VM_Network.Value = $fd.network
187190 Write-Output " OVF: $ ( $ovfConfig ) "
188191 $jobs += Start-ThreadJob - n " upload-template-$ ( $fd.cluster ) " - ScriptBlock {
189- param ($Version , $vm_template , $ovfConfig , $vmhost , $datastoreInfo , $folder , $tag , $scriptdir )
192+ param ($Version , $vm_template , $ovfConfig , $vmhost , $datastoreInfo , $folder , $tag , $scriptdir , $cliContext )
190193 . .\variables.ps1
191194 . ${scriptdir} \upi- functions.ps1
192195 Write-Output " Version: $ ( $Version ) "
193196 Write-Output " VM Template: $ ( $vm_template ) "
194197 Write-Output " OVF Config: $ ( $ovfConfig ) "
195198 Write-Output " VM Host: $ ( $vmhost ) "
196- Connect-VIServer - Server $vcenter - Credential ( Import-Clixml $vcentercredpath )
199+ Use-PowerCLIContext - PowerCLIContext $cliContext
197200 $template = Import-Vapp - Source " template-$ ( $Version ) .ova" - Name $vm_template - OvfConfiguration $ovfConfig - VMHost $vmhost - Datastore $datastoreInfo - InventoryLocation $folder - Force:$true
198201
199202 $templateVIObj = Get-View - VIObject $template.Name
@@ -212,7 +215,7 @@ foreach ($fd in $fds)
212215 New-AdvancedSetting - Entity $template - name " disk.EnableUUID" - value ' TRUE' - confirm:$false - Force > $null
213216 New-AdvancedSetting - Entity $template - name " guestinfo.ignition.config.data.encoding" - value " base64" - confirm:$false - Force > $null
214217 # $snapshot = New-Snapshot -VM $template -Name "linked-clone" -Description "linked-clone" -Memory -Quiesce
215- } - ArgumentList @ ($Version , $vm_template , $ovfConfig , $vmhost , $datastoreInfo , $folder , $tag , $SCRIPTDIR )
218+ } - ArgumentList @ ($Version , $vm_template , $ovfConfig , $vmhost , $datastoreInfo , $folder , $tag , $SCRIPTDIR , $cliContext )
216219 }
217220}
218221
0 commit comments