osim_ans
osim_ans

Reputation: 457

Vmware PowerCLI: How to use Invoke-VMScript to run command in PowerShell with elevated admin privileges

I want to execute a command on one of the VMs remotely using the Invoke-VMScript cmdlet. I want to run it with elevated admin privileges (in the remote VM) where the ScriptText will execute, but it throws the following error.

Command:

Invoke-VMScript -ScriptText ' Start-Process powershell -ArgumentList "-c", "whoami" -verb RunAs ' -VM 'TEST-VM4105' -GuestUser 'username' -GuestPassword 'password' -Verbose

Error:

ScriptOutput
------------------------------------------------------------------------------------------------------------------------------------------------------------
|  Start-Process : This command cannot be run due to the error: This operation requires an interactive window station.
|  At line:1 char:5
|  + & { Start-Process powershell -ArgumentList "-c", "whoami" -verb RunAs ...
|  +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|      + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
|      + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------

Is there any simple or difficult way to achieve this ?

Upvotes: 0

Views: 275

Answers (0)

Related Questions