Difference between revisions of "Script Extracts and Examples (PowerCLI)"
Jump to navigation
Jump to search
m (→Available Metrics: Updated) |
m (→Script Extracts: Added Synrtax Highlighting) |
||
Line 272: | Line 272: | ||
=== VM's with Datastores List === | === VM's with Datastores List === | ||
List of Virtual Machines, and their datastores (with usage) | List of Virtual Machines, and their datastores (with usage) | ||
<source lang="powershell"> | |||
$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" | |||
</source> | |||
=== VM's with Host and Cluster List === | === VM's with Host and Cluster List === | ||
<source lang="powershell"> | |||
$vms = Get-VM | sort -property Name | |||
foreach ($vm in $vms) | |||
{ | |||
$vm | Get-Cluster | Select-Object @{Name="VM"; Expression={$vm.name}},@{Name="Current Host"; Expression={$vm.host}},Name | |||
} | |||
</source> | |||
=== VM's Inventory CSV === | === VM's Inventory CSV === | ||
< | <source lang="powershell"> | ||
$start = Get-Date | $start = Get-Date | ||
Line 338: | Line 342: | ||
$table | Format-Table | $table | Format-Table | ||
$table | Export-Csv -path result.csv | $table | Export-Csv -path result.csv | ||
</ | </source> | ||
[[Category:VMware]] | [[Category:VMware]] | ||
[[Category:PowerShell]] | [[Category:PowerShell]] |