Running commands in the guest OS
To run a command on the guest operating system of a virtual machine, you can use the Invoke-VMScript
cmdlet. To use this cmdlet, the virtual machines must be powered on and must have VMware Tools installed. You also need network connectivity to the ESXi server hosting the virtual machine on port 902.
The Invoke-VMScript
cmdlet has the following syntax:
Invoke-VMScript [-ScriptText] <String> [-VM] <VirtualMachine[]>
[-HostCredential <PSCredential>] [-HostUser <String>]
[-HostPassword <SecureString>] [-GuestCredential <PSCredential>]
[-GuestUser <String>] [-GuestPassword <SecureString>]
[-ToolsWaitSecs <Int32>] [-ScriptType <ScriptType>] [-RunAsync]
[-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
The -ScriptText
and -VM
parameters are required. The value of the -ScriptText
parameter is the text of the script you want to run...