VMware Cloud Community
pbalderos
Enthusiast
Enthusiast

Need a script to connect to vCenter, and get vCPU (vCPU, Sinfo on all virtual machines

Hello all!

We are about to go though a OS lic audit and I am trying to collection info on our virtual machines vCPUs. I would like to do this

via PowerCli or power shell, what ever works. In short I am trying to gather vCPU info on each virtual machines in vCenter.

Below are the steps. Does anyone have a script that could help? 

1) Connect to our vCenter server

2) Gather the following info and send it out to a csv (I would prefer Excel but not sure if that is possible)

  a. Virtual machine name

  b. Assigned host to that vm

  c. vCenter name (not criticle but nice to have as reference)

  d. Number of vCPUs that the virtual machines has assigned to it

  e. Number of virtual sockets on that virtual machine

  g. number of cores per socket on that virtual machine

Thanks in advance

Phillip Balderos VCP6-DCV
Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

Thread moved to the PowerCLI Community.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership

Try like this.

It expects that you are connected to one or more vSphere Servers.

$report = foreach($vc in $global:DefaultVIServers){

    Get-VM -Server $vc |

    Select @{N='vCenter';E={$vc.Name}},

        @{N='VMHost';E={$_.VMHost.Name}},

        @{N='VM';E={$_.Name}},

        @{N='vCPU';E={$_.NumCpu}},

        @{N='CPU sockets';E={$_.NumCpu/$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},

        @{N='Cores/socket';E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}}

}

$report | Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
pbalderos
Enthusiast
Enthusiast

Thanks could you please also add a line to list the operating system version of the virtual machines? I forgot I need this info for the audit also.

Phillip Balderos VCP6-DCV
Reply
0 Kudos
LucD
Leadership
Leadership

See Re: Need help adding a command to also list the VMs guest OS1. Re: Need help adding a command to also list the VMs guest OSRe: Need help adding a command to also list the VMs guest OS


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos