[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 647
  • Last Modified:

Powershell Command for VM's

HI Guys,

I need a powershell, power cli command to find out the cpu quatity and the core settings for every VM in my environment, I then need this data to be outputted to an excel spreadsheet, how can I do this?

Thank you in advance,

Kay
0
Kay
Asked:
Kay
  • 2
3 Solutions
 
AbhilashCommented:
Its a easy task. You need powercli installed on a machine from where you can connect to your ESXi/vCenter. Open PowerCli and run the ConnectVI-Server cmdlet and connect to your ESXi/vCenter server.

Run the command :  Get-VM | Out-File C:\Report.csv
0
 
KayAuthor Commented:
I have got this code which works

Get-VM dev* | Select Name,
  @{N="CPU Sockets";E={$_.ExtensionData.Config.Hardware.NumCPU}},
  @{N="Cores per Socket";E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}} | Out-File -FilePath c:\users\kelly\vms.xls

Open in new window



however I need the datacentre name and I need them to be in separate cells in excel, please help!

right now in the excel spread sheet everything comes up in a single cell
0
 
Raheman M. AbdulCommented:
Download the function export-xls from tech gallery and it would be much easier for you.
http://gallery.technet.microsoft.com/office/d41565f1-37ef-43cb-9462-a08cd5a610e2

#=========================
# export-xls definition goes here
#then the following code:
Get-VM dev* | Select Name,
  @{N="CPU Sockets";E={$_.ExtensionData.Config.Hardware.NumCPU}},
  @{N="Cores per Socket";E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}} | export-xls -FilePath c:\users\kelly\vms.xls -NoTypeInformation
0
 
KayAuthor Commented:
that's the best solution.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now