Get-vSocket PowerCLI script

I just created a PowerCLI script for exporting all your VMs with vCPU and vSocket count to a CSV file.
You can download the script using the link below.
Script download

#General information
#Date: June 6th, 2013
#Author: Rene Bos
#URL: http://blog.stormdesigns.nl
#Script version: 0.1

#Script summary
#Tested on vCenter Server and ESXi 5.1
#This script will retreive the vCPUs and vSockets for each VM and will export this information in a table-like format to a CSV file.
#You need VMware PowerCLI installed on your machine and an active connection to one or more vCenter servers.

#Disclaimer
#Please use this script at your own risk and test it out in your testlab first before using it in production
#When using my script, please leave the general information in place. And let me know if my scripts needs improvement!

#Customizations
$CsvPath = "C:TempGet-vSocket.csv"

#Variables
$VMs = Get-VM

foreach ($VM in $VMs)
{
Write-Host "Getting information for $VM.name"
$VMview = Get-VM $VM | Get-View

$a = [PSCustomObject]@{
Hostname = $VM.name
NumCPU = $VMview.Config.Hardware.NumCPU
NumCoresPerSocket = $VMview.Config.Hardware.NumCoresPerSocket
}
$a | Export-CSV -Path $CsvPath -Append
}
Write-Host "CSV file is ready"

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s