Hello all,
I’modify a script for doing some OVA image of a vApp.
The script is this :
# # Adding the PowerCLI Modules Add-pssnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue # Clear the Screen and Make a Menu clear write-host "" write-host " PLEASE ENTER IN THE ZETTAGRID ZONE..." -ForegroundColor Green write-host "" write-host " 1. PERTH ZONE" write-host " 2. SYDNEY ZONE" write-host " 3. MELBOURNE ZONE" write-host "" $answer = read-host "Please Make a Selection" # Set the Zone from the Menu Option Selected otherwise Exit - No Fancy While Loop if ($answer -eq 1) { $zone='mycloud.per.zettagrid.com' } elseif ($answer -eq 2) { $zone='mycloud.syd.zettagrid.com' } elseif ($answer -eq 3) { $zone='mycloud.mel.zettagrid.com' } else { write-host "You choose....poorly" exit } # Get the arguments needed for the OVFTOol to Connect and Download the vApp write-host "" $username=read-host "Enter in your vCloud Username" $password=read-host "Enter in your vCloud Password" -AsSecureString $vCD_ORG=read-host "Enter in your vCloud Organisation" $vDC=read-host "Enter in your vCloud Virtual Datacenter" $vApp=read-host "Enter in your vApp" $catalog=read-host "Enter in your vCD Catalog" Write-Host -NoNewline -ForegroundColor Red "Enter In the Full OVA Path" $OVA=read-host " :" write-host "" #Convert Secure Password $password_converted = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) # Build the vCloud Connection String $vCloud="vcloud://${username}:${password_converted}@${zone}:443?org=${vCD_ORG}&vdc=${vDC}&vapp=${vApp}&catalog=${catalog}" #Build the vCloud Connection String to Hide Password $vCloud2="vcloud://${username}:*******@${zone}:443?org=${vCD_ORG}&vdc=${vDC}&vapp=${vApp}&catalog=${catalog}" write-host "vCloud Connection String" $vCloud2 -ForegroundColor Yellow write-host"" # Set the OVFTool EXE and execute it with some arguments $app = '.\ovftool.exe' $arg1 = "$OVA" $arg2 = "$vCloud" & $app $arg1 $arg2 write-host "" read-host "Hit Enter to Exit"
My problem is when i tape the command line directly in powershell (PowerCLI):
$vCloud="vcloud://${username}:${password_converted}@${zone}:443?org=${vCD_ORG}&vdc=${vDC}&vapp=${vApp}&catalog=${catalog}"
Of course all the variable is set before.
I have the error :
“Unexpected token ‘&’ in expression or statement. The ampersand (&) character is not allowed…”
Have you an idea ?
Thx for help.