Script Extracts and Examples (PowerCLI): Difference between revisions

From vwiki
Jump to navigation Jump to search
(Initial creation + "VM Datastores")
 
m (Minor correction)
Line 7: Line 7:
  $datastoreExp = @{N="Datastore"; E={ ($_ | get-datastore | select-object -first 1).Name }}
  $datastoreExp = @{N="Datastore"; E={ ($_ | get-datastore | select-object -first 1).Name }}
  $diskSizeExp = @{N="Total Disk"; E={ ($_ | get-harddisk | measure-object -property CapacityKB -sum).Sum }}
  $diskSizeExp = @{N="Total Disk"; E={ ($_ | get-harddisk | measure-object -property CapacityKB -sum).Sum }}
  get-vm | select Name, $datastoreExp, $diskSizeExp | sort -property Datastore,"Total Disk"</code>
  get-vm | select Name, $datastoreExp, $diskSizeExp | sort -property Datastore,"Total Disk"

Revision as of 14:42, 17 August 2009

Before being able to use any the following script you need to install...

VM Datastores

List of Virtual Machines, and their datastores (with usage)

$datastoreExp = @{N="Datastore"; E={ ($_ | get-datastore | select-object -first 1).Name }}
$diskSizeExp = @{N="Total Disk"; E={ ($_ | get-harddisk | measure-object -property CapacityKB -sum).Sum }}
get-vm | select Name, $datastoreExp, $diskSizeExp | sort -property Datastore,"Total Disk"