Welcome to Powergui.org - an open source community for Windows Powershell

PowerGUI.org PowerGUI.org and blogs

Forums » Request a Script

Thread: VMware script missing

This question is not answered. Helpful answers available: 2. Answered answers available: 1.


Permlink Replies: 3 - Pages: 1 - Last Post: Nov 26, 2009 3:53 PM by: powergoofy
Netbuster

Posts: 2
Registered: 11/13/09
VMware script missing
Posted: Nov 13, 2009 1:10 AM
 
  Click to reply to this thread Reply

Hi folks,
im looking for a script to query some informations out of a VirtualCenter Server...
What i need as the output is a sheet lokking like this:

VMName | HDDsize1 | ...| HDDsize4 | Snapshotsize | NumOfSnapshots | NumOfCPU | Memorysize

Did anyone knows about a script like this???

Thanx,

Netbuster


Netbuster

Posts: 2
Registered: 11/13/09
Re: VMware script missing
Posted: Nov 23, 2009 11:24 PM   in response to: Netbuster
 
  Click to reply to this thread Reply

No one can help ??? 




gareth.mcguinness_000

Posts: 54
Registered: 8/25/09
Re: VMware script missing
Posted: Nov 24, 2009 1:37 AM   in response to: Netbuster
 
  Click to reply to this thread Reply

Have you tried the powerpack below within powergui - this might be able to give you the relevant info:

http://www.powergui.org/entry.jspa?externalID=2551&categoryID=21

This should also give you some of the info as well - this is a copy of a script that I changed slight as the export-csv was not handling the different number of properties per object. The edit is a bit of a work around but it might help

Cheers
Gareth

param (

[string]$VCServer = $(throw "You must enter a VC Server"),[

string]$Cluster = $(throw "You must select a Cluster"), [string]$file = $(throw "You must enter the filename to export to")

)

$Header = "Name" + ","+ "ResPool" + ","+ "VCPUs" + ","+ "cpuRes" + "," + "memRes" + "," + "memOverhead" + "," + "vmdkSize1 - GB" + "," + "Datastore1" + "," + "vmdkSize2 - GB" + "," + "Datastore2"

$Header | out-file $file

connect-viserver $VCServer

$vmhostsview = get-cluster $Cluster | get-vmhost | get-view

$vmtable = @()

foreach($vmhost in $vmhostsview){

if ($vmhost.vm -ne $null){

foreach($vm in (get-view $vmhost.vm)) {

$vminfo = New-Object psobjectAdd-Member -InputObject

$vminfo -membertype NoteProperty Name $vm.name

if($vm.resourcepool -ne $null){Add-Member -InputObject

$vminfo -membertype NoteProperty ResPool (get-view $vm.resourcepool).name

}

Add-Member -InputObject
$vminfo -membertype NoteProperty VCPUs $vm.summary.config.NumCpu

Add-Member -InputObject $vminfo -membertype NoteProperty cpuRes $vm.summary.config.CpuReservationAdd-Member -InputObject

$vminfo -membertype NoteProperty memRes $vm.summary.config.MemoryReservation

Add-Member -InputObject $vminfo -membertype NoteProperty memOverhead $vm.summary.runtime.memoryoverhead

$HDDNum = 1foreach ($HDD_Device in ($vm.config.hardware.device | where {$_.controllerkey -eq 1000}))

{

$vmdksizekeyname = "vmdkSize$HDDNum"

$Datastorekeyname = "Datastore$HDDNum"

Add-Member -InputObject $vminfo -membertype NoteProperty $vmdksizekeyname $HDD_Device.CapacityinKB -ErrorAction SilentlyContinue

Add-Member -InputObject $vminfo -membertype NoteProperty $Datastorekeyname (get-view $HDD_Device.backing.datastore).summary.name -ErrorAction SilentlyContinue

$HDDNum++

}

$vmtable += $vminfo



$Output = $vminfo.Name + "," + $vminfo.ResPool + "," + $vminfo.VCPUs + "," + $vminfo.cpuRes + "," + $vminfo.memRes + "," + $vminfo.memOverhead + "," + $vminfo.vmdkSize1 /1048576 + "," + $vminfo.Datastore1 + "," + $vminfo.vmdkSize2 / 1048576 + "," + $vminfo.Datastore2 + "," + $vminfo.vmdkSize3 / 1048576 + "," + $vminfo.Datastore3
$Output | out-file $file -Append

}

}

}

disconnect-viserver -confirm:$false

Message was edited by: gareth.mcguinness_000


powergoofy

Posts: 13
Registered: 5/24/09
Re: VMware script missing
Posted: Nov 26, 2009 3:53 PM   in response to: Netbuster
 
  Click to reply to this thread Reply

If you don't get anywgere after trying that or any other assistance - try rvtools - google it.


Legend
MVP: 2501 + pts
Guru: 2001 - 2500 pts
Expert: 751 - 2000 pts
Enthusiast: 31 - 750 pts
Novice: 0 - 30 pts
Moderators
Helpful answer (5 pts)
Answered (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums