# VMware PowerCLI
# Install PowerCLI on Linux
Install PowerShell.
# Register the Microsoft RedHat repositorycurl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShellsudo dnf install --assumeyes powershell
# Start PowerShellpwsh
Install PowerCLI module online.
PS C:\> Install-Module -Name VMware.PowerCLI
Option, install PowerCLI module offline.
Download the PowerCLI ZIP file from the PowerCLI home page and transfer the ZIP file to your local machine.
# To view the folder paths to which you can extract the PowerCLI ZIP file, run the command:$env:PSModulePath# Extract the contents of the PowerCLI ZIP file to one of the listed folders.unzip -q -d <PSModulePath> <PowerCLI ZIP file>
# For Windows, run the command to unblock the copied files.Get-ChildItem -Path 'unzipped_folder_path' -Recurse | Unblock-File
Verify that the VMware PowerCLI modules have installed successfully.
Get-Module VMware* -ListAvailable
# Commands Reference
・ VMware vSphere And vSAN cmdlets
# Connects to a vSphere server. | |
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore | |
Connect-VIServer -Protocol https -User 'administrator@vsphere.local' -Password 'Welcome@123' -Server 192.168.3.199 | |
# PowerOff / PowerOn VM | |
Get-VM "Remote-Machine (3.86)" | Stop-VM | |
Get-VM "Remote-Machine (3.86)" | Start-VM | |
# Get VMs creation date, vSphere 6.7 or latest. | |
Get-VM | Select-Object Name, | |
@{N="CreationDate"; E={$_.ExtensionData.Config.CreateDate}} | |
# Find out used and provisioned disk size for a specific virtual machine. | |
Get-VM -Name "Remote-Machine (3.86)" | Select Name, | |
@{N='Used (GB)';E={[math]::Round($_.UsedSpaceGB,2)}}, | |
@{N='Provisioned (GB)';E={[math]::Round($_.ProvisionedSpaceGB,2)}} | Format-List |