Difference between revisions of "Script Extracts and Examples (PowerCLI)"

Jump to navigation Jump to search
m
Typo fix
m (Minor editrs)
m (Typo fix)
 
(97 intermediate revisions by the same user not shown)
Line 1: Line 1:
Before being able to use any the following script you need to install...
#REDIRECT [[:Category:PowerCLI]]
* [http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx Windows PowerShell]
* [http://www.vmware.com/go/powershell VI Toolkit]
 
== Getting Started ==
 
On the first run you need to allow the Toolkit to run properly by running...
Set-ExecutionPolicy RemoteSigned
 
Connect to the Virtual Centre using the following command using your normal username and password (same as you'd use to log into the VI Client).  You will need access to the servers on TCP 443.
Connect-VIServer -Server uklonvcp1 -User <user> -Password <pass>
 
== 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"

Navigation menu