Skip to main content

Script to Check (VMware) Virtual Machine Power State

Here is a script to check Power state of a VM using power shell.

Create the .csv file (vmlist.csv) with header name as "name" and list all the VMs under it, for which power state needs to be determined. Enter the appropriate vCenter name to connect to the vCenter. The list of VMs and its power state will be displayed on the screen.

Add-PSSnapin VMware.VimAutomation.Core   (For vSphere 5.5 or below)
Import-Module VMware.VimAutomation.Core  (For vSphere 6.0 and above) 
Connect-VIServer vCenterName

$vms = Import-csv "C:\temp\vmlist.csv"
foreach ($vm in $vms)
{
$p = get-vm $vm.name | Select-Object Powerstate
$q = ($p).powerstate
Write-output "$($vm.name) `t $($q)"
}


Comments

Popular posts from this blog

Upgrading HPE 3PAR SRA (Storage Replication Adapter) from 6.1 to 6.5

Here  are the high level step to upgrade the HPE 3PAR Storage Replication Adapter (SRA) - If old SRA is visible in add remove programs -  View certificates for old array (that will be removed after migration) from SRM server using following path and TPDsrm utility -        C:\Program Files\VMware\VMware Site Recovery manager\Storage\SRA\3Parinsrv>              TPDsrm.exe viewcert Uninstall old 3PAR SRA from SRM server using uninstall program feature. Reboot the SRM server. Install new 3PAR SRA using the .exe file provided by vendor. Check if you can see the new SRA in Program list. If so, reboot the SRM server.  Validate certificates for new array using following path and command on SRM server -        C:\Program Files\VMware\VMware Site Recovery manager\Storage\SRA\3Parinsrv>               TPDsrm.exe validatecert -s...

How to Check Up Time of ESXi Host or Virtual Machine from vCenter Server

To check up time of ESXi host from vCenter server - Logon to vCenter Server -  If using C# (fat) client - click on cluster - on right side pane click on Hosts - select the up time option by right clicking on the header. The column will be added at the end. You can drag and drop column to place it in your view. If using HTML client - click on cluster - on right side pane click on Hosts - select the up time attribute from show/hide column by clicking on the header  If using web (Flash)  client - click on cluster - on right side pane click on related objects - hosts - right click on the header to show/hide column - click on up time attribute Similarly,  you can check the up time for a virtual machine by clicking on the virtual machine tab instead of host tab, but only caveat  is vCenter gives you up time of a virtual machine according to reboots performed from the vCenter. So, rather than rebooting server fr...