PowerShell / PowerCLI automation

This page collects practical PowerShell and PowerCLI scripts used to automate real infrastructure tasks, with short explanations and ready‑to‑copy examples.

VM power operations

Scripts to start, stop and restart virtual machines in a controlled, auditable way.

Power on or shut down a VM (vSphere)

Simple PowerCLI example to connect to vCenter and power on or power off a single VM by name.

Script


# Connect to vCenter
Connect-VIServer -Server "vcsa01.lab.local"

# Power on a VM
Get-VM -Name "VM-NAME" | Start-VM

# Power off a VM (graceful)
Get-VM -Name "VM-NAME" | Stop-VM -Confirm:$false
      

View script (.ps1) | Download script (.zip)