Thursday, March 5, 2015

Powershell - How to Get Disk and CPU Information from Remote Computers

Quick one liner:

We've been working with consultants to evaluate our current infrastructure and they requested information regarding the disks and CPUs of our physical servers.

1. Create a csv file with the servers you wish to query in the following format:

2. This one-liner pulls the servers to be queried from the server1.csv file.  It then injects the server names into the Get-WmiObject command.  Finally, it dumps the output into the serverstorage.csv file.

For Disk info:
Import-Csv E:\server1.csv | ForEach-Object {Get-WmiObject Win32_LogicalDisk -ComputerName $_.server} | export-csv -path e:\serverstorage.csv

For CPU info:
Import-Csv E:\server1.csv | ForEach-Object {Get-WmiObject Win32_processor -ComputerName $_.server} | export-csv -path e:\cpuinfo01.csv

The dumps created provide heaps of details.  Here's some of the more key columns.
Example Output:

Quick and easy.

11.18.15 Update.

For Memory info:
Import-Csv E:\server1.csv | ForEach-Object {Get-WmiObject Win32_physicalmemory -ComputerName $_.server} | export-csv -path e:\servermemory.csv

The disk size is in Bytes.  To convert it to GB, I just use the following formula in Excel:

=A1/(1024*1024*1024)

vCenter - Updating Hardware data... No new host data available. Data will be updated in 5 minutes

I had a yellow bang on one of my ESXi hosts.  The alarm was for Host memory Status.  When I went to the Hardware Status tab I had the following: Updating Hardware data...

After a few minutes, I would then get: No new host data available.  Data will be updated in 5 minutes


This was occurring on all of the hosts on this particular vCenter server.  I tried restarting the Inventory Service, VirtualCenter Server service and the entire server.  No Go

I then performed the fixes on VMware KB 2015838.   None of them resolved the issues.  Looks like it's an issue with the Inventory Service database....

The Inventory Service houses tags used within the vCenter Web Client.  Tagging replaced the custom attributes functionality found in the vCenter Server.  (Tags are bypassed when using the C# vSphere Client),  The Inventory Service also houses all Storage Profiles that you are using via the vSphere Profile-Driven Storage service.

Fortunately, I performed a recent backup of the Inventory Service Database.  To restore the DB, perform the following:

1. Stop the vCenter Inventory Service.
2. Drill down to the following directory.
C:\Program Files\VMware\Infrastructure\Inventory Service\scripts.
3. Run the following command.
restore -backup backup_file_name  

4. Start the vCenter Inventory Service.
5. Confirm that the hardware status tab is now visible.



To learn how to backup the Inventory Service database, check out my following post:
http://kenumemoto.blogspot.com/2014/09/vcenter-inventory-service-database.html


If you do not have a backup of the Inventory Service database, you will have to reset the DB as descriped below:
 
Additional Info:

Resetting the Inventory Service database:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2042200

Backing up the Inventory Service database fails with an authentication error:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2068719 

vCenter Inventory Service Fails to start and cannot backup up the Inventory Service database:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2017370


Inventory Service Backup Failed - Error: IO_ERROR, Original message: Software caused connection abort: recv failed

When performing a backup of the Inventory Service Database I received the following error:

Error: IO_ERROR, Original message: Software caused connection abort: recv failed. 


Quick fix:  Stop the VMware vCenter Inventory Service Service, then re-run the backup.