Thursday, March 27, 2008

VMWare Power Shell

vm infrastructure toolkit for windows

provides a core set of powershell cmdlets

for managing vi.
- Focuses on virtual machine lifecycle
eg: get-vm; new-vm; remove-vm; set-vm;

start-vm; stop-vm etc

- Core infrastructure management
eg: get-log; get-task etc

USAGE
First thing to do after launching powershell

with vm toolkit is to get connection to a

virtualcenter or esx server

Use get-viserver or get-vc/get-esx with the

address of virtuacenter or esx server

eg: get-viserver 1.2.3.4 you are then

prompted for username & password

Use without parameters and powershell will

prompt you for everything

After establishing session you are able to

use rest of the provided cmdlets.
Session information is stored in a

powershell variable $defaultviserver

Further cmdlet invocations will get their

server information from that variable unless

explicitly specified to use another server

BROWSE ENVIRONMENT
get-vm - To get all virtual machines on the

connected server

get-vmw web* or get-vm | where ($_.name -

like "web*") - To get all virtual machines

starting with the name "web"

get-folder webTier | get-vm - To get all

virtual machines under webTier folder

get-folder webtier | get-vm | where

(&_.pwerstate -ne "poweredon") | start-vm -

T start all virtual machines under webtier

flder that are nt currently powered on

No comments: