$src2 = @'&"$env:C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe" "$env:/s /v "/qb INSTALL_VDISPLAY=1 VDM_VC_MANAGED_AGENT=1 ADDLOCAL=Core,USB,VmwVaudio,VmwVidd,ScannerRedirection,PrintRedir,RTAV,ClientDriveRedirection,V4V,GEOREDIR,PerfTracker""'
Invoke-VMScript -ScriptType powershell -ScriptText $scr2 -VM $TeplateVMName -GuestCredential $Cred
I have also attempted this way
$code1 = @'
C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe /s /v '"/qb INSTALL_VDISPLAY=1 VDM_VC_MANAGED_AGENT=1 ADDLOCAL=Core,USB,VmwVaudio,VmwVidd,ScannerRedirection,PrintRedir,RTAV,ClientDriveRedirection,V4V,GEOREDIR,PerfTracker"'
'@
Invoke-VMScript -scripttype Powershell -scripttext $code1 -VM $TeplateVMName -GuestCredential $Cred
Can you try with just
$code = @'
C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe /s /v "/qn INSTALL_VDISPLAY=1 VDM_VC_MANAGED_AGENT=1 ADDLOCAL=Core,USB,VmwVaudio,VmwVidd,ScannerRedirection,PrintRedir,RTAV,ClientDriveRedirection,V4V,GEOREDIR,PerfTracker"
'@
Invoke-VMScript -ScriptType Bat -ScriptText $code -VM $TeplateVMName -GuestCredential $Cred
That seems to work for me.
Two changes:
- use single quotes on the here-string
- use Scripttype Bat, since this is just a regular EXE, no PS required
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Your 1st snippet has an incorrect here-string, and the variable name used in the Invoke-VMSCript is not correct.
That should be
$src2 = @'
&"$env:C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe" "$env:/s /v "/qb INSTALL_VDISPLAY=1 VDM_VC_MANAGED_AGENT=1 ADDLOCAL=Core,USB,VmwVaudio,VmwVidd,ScannerRedirection,PrintRedir,RTAV,ClientDriveRedirection,V4V,GEOREDIR,PerfTracker""
'@
Invoke-VMScript -ScriptType powershell -ScriptText $src2 -VM $TeplateVMName -GuestCredential $Cred
The command runs under the account that the VMware Tools are running under.
Is that account allowed to do installations?
Do you hit the UAC prompt?
Because then the command will time out.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Running into this with a copy and paste of your edits
At line:1 char:26
+ & {&"$env:C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe" "$env:/s /v "/qb INSTALL_VDISPLAY=1 VDM_VC_MA ...
+ ~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to
The guest creds I am using are a local admins account and when I log into the machine and run the silent installer I do not get prompted with the UAC.
Looks like your copy/paste has an issue.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
it looks like the problem is the second part it does not like after the second $env.
"$env:/s /v "/qb INSTALL_VDISPLAY=1 VDM_VC_MA .
What is the actual command you want to run inside the Guest OS?
I'm not sure I understand the use of the $env variable.
In a here-string with single quotes there is no variable substitution, so the $env will be passed to the Guest OS
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe /s /v "/qn INSTALL_VDISPLAY=1 VDM_VC_MANAGED_AGENT=1 ADDLOCAL=Core,USB,VmwVaudio,VmwVidd,ScannerRedirection,PrintRedir,RTAV,ClientDriveRedirection,V4V,GEOREDIR,PerfTracker"
And what is the idea behind that $env in the code?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
honestly I was just trying it since it didn't work the other way as well. I need the quotes in the command I think those are messing it up. I also just tried putting it in the invoke-vmscript in the -scripttest with {} around it and it kept not sending the whole thing.
Can you try with just
$code = @'
C:\VMware-Horizon-Agent-x86_64-2111.1-8.4.0-19066669.exe /s /v "/qn INSTALL_VDISPLAY=1 VDM_VC_MANAGED_AGENT=1 ADDLOCAL=Core,USB,VmwVaudio,VmwVidd,ScannerRedirection,PrintRedir,RTAV,ClientDriveRedirection,V4V,GEOREDIR,PerfTracker"
'@
Invoke-VMScript -ScriptType Bat -ScriptText $code -VM $TeplateVMName -GuestCredential $Cred
That seems to work for me.
Two changes:
- use single quotes on the here-string
- use Scripttype Bat, since this is just a regular EXE, no PS required
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
🎉
Perfect, That worked, thank you. I was about to give up and write the one-liner and push the script to the guest and run it with the invoke-vmscript!