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

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...

Initial Configuration of VMware NSX Manager

Here are the steps for the initial configuration of VMware NSX Manager-  Deploy NSX Manager for the vCenter. NSX manager and vCenter have 1:1 binding, so if there are multiple vCenters - multiple NSX manager needs to be deployed each in one vCenter Once NSX manager is deployed, logon to the NSX manager using the IP address or the FQDN of the NSX manager Configure the NTP settings by clicking on "View Summary" on home page and then clicking Configure NTP Servers from Manage - General - Time Setting  Once the NTP time settings are configured, configure look up service and vCenter Server to connect to the NSX manager. Click on manage vCenter registration and click on configure look up service to configure the lookup service. Accept the SSL certificate. Once Lookup service is connected successfully, register the vCenter to the NSX Manager. Note - SSO admin account (administrator@domain.local) needs to be used for the configuration of look up service and registration o...

VMware vCenter 5.5 getting Disconnected Sporadically

I recently experienced an issue with vCenter 5.5 was getting disconnected sporadically. vCneter was running on windows 2012 server. I was able to see following errors in windows logs. vCenter Logs were showing following errors -          2018-08-18T01:30:03.630-04:00 [11432 error 'Default' opID=92132b4] An unrecoverable problem has occurred, stopping the VMware VirtualCenter service. Error: Error[VdbODBCError] (-1) ODBC error: (08S01) - [Microsoft][SQL Server Native Client 11.0]TCP Provider: The specified network name is no longer available.         2018-08-18T01:30:03.630-04:00 [11432 error 'Default' opID=92132b4] An unrecoverable problem has occurred, stopping the VMware VirtualCenter service. Error: Error[VdbODBCError] (-1) ODBC error: (08S01) - [Microsoft][SQL Server Native Client 11.0]TCP Provider: The specified network name is no longer available.         2018-08-19T19:28:31.801-04:00 [06368 warning...