PowerShell is a Microsoft command interpreter that is installed with recent Windows releases. PowerCLI, a VMware product, is an add-on module for PowerShell that is designed to support vSphere administration.

If you need to run PowerCLI on non-Windows systems, you an use Powershell Core, an open-source version of PowerShell that is compatible with Powershell scripts and most modules.

Prerequisites

  • Install PowerCLI (see the VMware PowerCLI Installation Guide) on a machine that has network connectivity to your SDDC's vCenter (see Configure a VPN Connection Between Your SDDC and On-Premises Data Center in the VMware Cloud on AWS Networking and Security guide).
  • Use the CMDLET References by Product to find the commands required and their syntax.
  • Connect to your SDDC's vCenter (or other management appliance such as HCX Manager or SRM) following the instructions in the relevant product reference.

Procedure

  1. Verify that the VM is running the latest version of VMware Tools.
  2. Verify that you can access the Guest Operations API, either directly or via a simple PowerCLI cmdlet.
    You could use a cmdlet like this one to test your ability to reach port 443 on the ESXi host with IP address 10.100.1.1.
    PS C:\Users\admin>Test-NetConnection -Port 443 -ComputerName 10.100.1.1
    A response of True or TcpTestSucceeded indicates a successful test.

Example: Using the PowerCLI Invoke-VMScript Cmdlet

After you establish a network connection that allows traffic to port 443 on your hosts, you can use the Guest Operations API directly, or via PowerCLI as shown here. API and cmdlet requests go to port 443 on the host where the subject VM (Win10-Example here) is running. VMware Tools running on the VM handles the requested guest operations.

PS C:\Users\admin> $vm = Get-VM Win10-Example
PS C:\Users\admin> Invoke-VMScript -ScriptText "dir C:\" -VM $vm -GuestUser admin -GuestPassword $passwd"

ScriptOutput
------------------------------------------------------
|
| Directory: C:\
|
| ...