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>] ...

Get Learning PowerCLI - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.