PowerCLI Getting Started

PowerCLI Basics

PowerCLI Code

Some basic PowerCLI commands

#Here are some basic commands that you can keep adding additional code
#and get more precise on what you want to see.

#Connect to a vCenter

Connect-VIServer vcsa.domain.org

#Disconnect from vCenter and not be prompted

Disconnect-VIServer vcsa.domain.org -confirm:$false

#Get VM Listing

#Shows all VMs

#Shows all VMs sorted by Name
Get-VM | Sort-Object Name

#Shows all VMs sorted by Name that are Powered On
Get-VM | Where-Object {$_.Powerstate -eq 'PoweredOn'} | Sort-Object Name

#Shows all VMs sorted by Name, that are Powered On and only shows
Get-VM | Where-Object {$_.Powerstate -eq 'PoweredOn'} | Sort-Object Name | Select-Object Name,MemoryGB,NumCpu

Related Posts

Welcome to www.vCROCS.info

Your Source for Automation/Monitoring/Logging Content I have learned a lot from the vCommunity, Powershell and PowerCLI web sites.

Read more

VMware vRealize SaltStack Config API

Using SaltStack Config api for Automation from vRA Catalog or cmd A personal goal of mine for 2022 was to start doing more with Python when working with VMware SaltStack Config.

Read more

VMware vRealize SaltStack Config as a Windows Server Admin - Part 9

Part 9: Using salt-api with PowerShell for Windows Server Automation This post is to show how to use PowerShell to make RESTful API calls to SaltStack Config.

Read more