There is a very usefull CMDLet Invoke-VMScript which comes with VMWare PowerCLI. You can use it to run the PowerShell scripts against a virtual machine (VM).
The CMDLet has several advantages over native PowerShell 2.0 remoting:
1. Avoiding one hop while executing the script (on the VM, the script is executed from the first person).
2. Ability to run the script against host-only VMs.
The only trouble is that this CMDLet returns the results as raw text which is not possible to handle like a PSObjects array.
To workaround this issue, you can use the following approach:
Invoke-VMScript -VM VirtualMachineName -ScriptText “Your script here | ConvertTo-CSV -NoTypeInformation” -HostUser root -HostPassword “rootpassword” -GuestUser DOMAIN\admin -GuestPassword “adminpassword” | ConvertFrom-CSV
This seven year old post helped me out. Thanks a bunch for this tip.
Konstantin this saves my life. Thanks very much
Nailed it!! Saved lot of time.
This nine year old post helped me out. awesome
This nine year old post helped me out. Awesome
This nine year old post helped me out. thank you!
This Script did the trick, very nice!
This 11 year old post was prescient to the need