← script library

Automating VMware vSphere VM Power On

VMware & vSphereJanuary 6, 2025

In this post, I will share a practical PowerShell script to automate the process of powering on a virtual machine (VM) in VMware vSphere. This script is handy for system administrators who manage multiple VMs and want to streamline their operations.

powershell
# Load VMware PowerCLI module
Import-Module VMware.PowerCLI

# Connect to the vSphere server
$vcServer = "your_vcenter_server"
$credential = Get-Credential -Message "Enter your vCenter credentials"
Connect-VIServer -Server $vcServer -Credential $credential

# Power on a specific VM
$vmName = "YourVMName"
Start-VM -VM $vmName
Write-Host "Virtual Machine $vmName is powering on..."

# Check the status of the VM
$vm = Get-VM -Name $vmName
Write-Host "Current Status of VM $vmName: $($vm.PowerState)"

# Disconnect from the vSphere server
Disconnect-VIServer -Server $vcServer -Confirm:$false
Write-Host "Disconnected from vSphere server."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.