MOCs
- Overview
- Installation
- Connecting to vSphere
- Virtual Machine Management
- Host and Cluster Management
- Networking Management
- Storage Management
- vCenter Server Appliance Management
- Working with VM Templates
- Snapshot Management
- PowerCLI Scripts
- Tips and Tricks
Overview
VMware PowerCLI is a command-line interface tool for managing VMware vSphere environments, leveraging the VMware vSphere API. It’s built on Windows PowerShell and provides more than 700 cmdlets for managing VMware products and services.
Documentation
Installation
Warning
Make sure you run
Set-ExecutionPolicy RemoteSigned
before running the following
- PowerCLI can be installed directly from the PowerShell Gallery:
Connecting to vSphere
- Connect to a vCenter Server or ESXi host:
Virtual Machine Management
- Creating a New VM:
- Starting a VM:
- Stopping a VM:
Host and Cluster Management
- Listing all ESXi Hosts:
- Adding a Host to a Cluster:
Networking Management
- Creating a Virtual Switch:
- Creating a Port Group:
Storage Management
- Listing Datastores:
- Creating a New Datastore:
vCenter Server Appliance Management
- Restarting vCenter Services:
Working with VM Templates
- Creating a VM Template:
- Deploying a VM from a Template:
Snapshot Management
- Creating a Snapshot:
- Removing a Snapshot:
PowerCLI Scripts
- PowerCLI can be used to script complex tasks, combining multiple cmdlets into scripts to automate repetitive tasks or to schedule operations.
Tips and Tricks
- Updating PowerCLI:
- Automating Tasks: Leverage PowerCLI to automate tasks such as VM deployment, configuration changes, and performance monitoring.
- Security Best Practices: Use secure methods for handling credentials, such as PowerShell’s secure string or credential store.