Hi there!
We got some problems with invoke-vmscript, the thing is that it work on some servers, but not all.
Example, 2 servers, same OS (2012R2) both on same VLAN, have the same VMWare Tools version.
Small example:
Invoke-VMScript -ScriptText 'whoami' -GuestCredential $creds -VM $VM -ScriptType Powershell
On one server i get output, on the other nothing, just:
ScriptOutput
------------------------------------
------------------------------------
Do you have any clue were to start troubleshooting? Thanks
Have a look in the vmware.log that belongs to the problematic VMs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Cant see anything strange in the logfile.
However.. a clue.
If i first login to the server with RDP (same creds) and then execute the invoke-vmscript i get output and it works.
If i then logout from RDP session, no output from Invoke-VMScript when trying again
That looks as if it might be a Windows profile issue.
When there is no profile for the user, it will not be created when logging on implicitly through Invoke-VMScript.
Can you run a simple command in DOS?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thats true, when were using BAT as scripttype it´s working.
That looks as if the PowerShell script hangs because it is looking for your PowerShell profile file.
The solution is to use the NoProfile parameter on the powershell.exe command (launch as BAT).
Try if this works.
$cmd = @'
powershell -NonInteractive -NoProfile -Command "Get-Process"
'@
Invoke-VMScript -VM $vm -ScriptText $cmd -ScriptType Bat
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference