Skip to content

NKCODE TECH GEEK ZONE

  • RSS - Posts
Menu
  • Home
  • Cloud
    • Azure
    • Alibaba
    • AWS
  • Hardware
  • Linux
  • Network
  • Security
  • Windows Client / Servers
    • SQL
    • Windows Client OS
      • Windows 10
    • Windows Servers
      • Windows 2008R2
      • Windows Server 2012R2
      • Windows Server 2016
      • Windows Server 2019
  • VMWARE
  • Free Tools
  • About Me
    • Disclaimer
Menu

VMware PowerCLI Installing the Module and Working with ESXi Host and vCenter

Posted on January 20, 2020

Installing VMware PowerCLI with PowerCLI module.

Run the command to check  VMware PowerCLI installed or Not.
Get-Module VMware.PowerCLI -ListAvailable
Installing the latest version of the module available from PowerShell gallery. Run Below Command to find the Module and Version.
Find-Module VMware.PowerCLI or (Find-Module VMware.PowerCLI).version

12.1.0.17009493 is the latest version that is available in PSGallery.

To install this module use: Install-Module VMware.PowerCLI

Once successfully installed you can verify using: Get-Module VMware.PowerCLI -ListAvailable


To list all the available cmdlets: Get-Command -Module VMware*


Now, let’s go ahead and connect to an ESXi host.Connect-VIServer <IP of ESXi server>



when trying to connect to ESXi host if show error please set the certification ignore and try again to Provide the necessary credentials and once connected successfully you will see the above.
To get details of the ESXi host: Get-VMHost <IP of ESXi server>

Working with vCenter server using VMWare.PowerCLI

Connect-VIServer <IP of vCenter server>

Get the list of data centers present under this vCenter server: Get-Datacenter

Get the list of clusters under a datacenter: Get-Datacenter nkcode-dc01 | Get-Cluster

 

To verify the status of HA, DRS, and vSAN of a cluster:

(Get-Cluster Cluster01) | select Name,DrsEnabled,DrsAutomationLevel,HAEnabled,HAFailoverLevel,VsanEnabled

 

Get the list of ESXi hosts part of a specific cluster:

Get-Datacenter nkcode-dc01 | Get-Cluster Cluster01 | Get-VMHost

 

To get the list of VMs hosted on a specific ESXi host:

Get-Datacenter nkcode-dc01 | Get-Cluster Cluster01 | Get-VMHost 192.168.1.130 | Get-VM

 

To get a list of powered on and powered off VMs:

(Get-Cluster Cluster01 | Get-VM).where{$PSItem.PowerState -eq “PoweredOn”}

(Get-Cluster Cluster01 | Get-VM).where{$PSItem.PowerState -eq “PoweredOff”}

 

An efficient way of doing it in a single go is given below:

$vmson, $vmsoff = (Get-Cluster Cluster01 | Get-VM).where({$PSItem.PowerState -eq “PoweredOn”}, ‘split’)

 

$vmson will have the list of VMs that are PoweredOn and $vmsoff will have the list of VMs that are PoweredOff.

 

Cluster level inventory:

Get-Cluster | Get-Inventory

 

Datastore details of a cluster:

Get-Cluster | Get-Datastore | select Name, FreeSpaceGB, CapacityGB, FileSystemVersion, State

For more VMWare.PowerCLI commands click here: https://code.vmware.com/docs/5579/vmware-vsphere-update-manager-powercli-cmdlets/doc/Overview.html

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

Welcome to Teck Geek Zone

Alibaba & Azure Cloud with a free trial worth $200-1200 USD Click below Cloud Providers

  • Securing Your Cloud Environment with Alibaba Cloud Firewall
  • 🚢 Sailing into the Data Age: How Cloud and IoT are Revolutionizing the Marine Industry
  • What is Azure Grafana? A Comprehensive Guide to Monitoring and Visualization
  • 🔐 How to Enable Virtualization-Based Security (VBS) for Windows Workloads in VMware Cloud Foundation and vSphere
  • Microsoft’s Azure SRE Agent: AI-Powered Reliability Engineering

Categories

  • Cloud (186)
    • Alibaba (39)
    • AWS (39)
    • Azure (114)
  • Free Tools (5)
  • Hardware (17)
  • Linux (13)
  • Network (28)
  • Security (21)
  • VMWARE (54)
  • Windows OS (44)
    • Windows 10 (7)
  • Windows Servers (69)
    • SQL (3)
    • Windows 2008R2 (7)
    • Windows Server 2012R2 (15)
    • Windows Server 2016 (20)
    • Windows Server 2019 (10)

Subscribe to our newsletter

©2025 NKCODE TECH GEEK ZONE | Design: Newspaperly WordPress Theme
 

Loading Comments...
 

    %d