automation using power cli

18
Automa’on Using PowerCLI Eric Wannemacher

Upload: esarakaitis

Post on 24-May-2015

749 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Automation using power cli

Automa'on  Using  PowerCLI  

Eric  Wannemacher  

Page 2: Automation using power cli

h9p://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Atlas_San'ago_Toural_GFDL.jpg/220px-­‐Atlas_San'ago_Toural_GFDL.jpg  

Page 3: Automation using power cli

Give  me  a  lever  long  enough  and  a  fulcrum  on  which  to  place  it,  and  I  shall  move  the  world.    Archimedes    

Page 4: Automation using power cli
Page 5: Automation using power cli
Page 6: Automation using power cli
Page 7: Automation using power cli
Page 8: Automation using power cli
Page 9: Automation using power cli
Page 10: Automation using power cli

vs.  

Page 11: Automation using power cli

How  Do  I  Use  It?  

•  Things  that  are  boring/repe''ve  – Server  builds  – LUN  migra'ons  – Changing  seRngs  across  many  hosts/VMs  – Reports  for  management/other  teams  – Managing  mul'ple  vCenters  

•  Things  I  should  do,  but  may  not  otherwise  – Configura'on  monitoring  – Log  review  

Page 12: Automation using power cli

GeRng  Started  

•  Install  PowerShell  (v2  if  possible)  •  Run  “Set-­‐Execu'onPolicy  RemoteSigned”  

•  Install  PowerCLI  4.0  U1  (Maybe  4.1)  

•  Connect-­‐VIServer  <host  or  vCenter>  •  MAGIC  

•  Disconnect-­‐VIServer  

Page 13: Automation using power cli

Demo  Recipes  

h9p://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Cheese_Soup_Recipe.jpg/800px-­‐Cheese_Soup_Recipe.jpg  

Page 14: Automation using power cli

Making  Toast  

# List all VMs Get-VM

# Get one VM Get-VM ubuntu01

# Get VMs that match Get-VM ubuntu*  

Page 15: Automation using power cli

Boiling  an  Egg  

# List VMs in a Datacenter

Get-Datacenter dc001 | Get-VM

# List VMs in a cluster

Get-Cluster dc001 | Get-VM  

Page 16: Automation using power cli

Sieing  Through  What  You  Have  

# Get 2 CPU or larger VMs Get-VM | Where-Object {$_.NumCPU -ge 2}

# Get 2 GB RAM or larger VMs Get-VM | Where-Object {$_.MemoryMB -ge 2048}  

Page 17: Automation using power cli

Available  Ingredients  

Get-Command Get-VICommand Summarized By Noun h9p://wannemacher.us/?p=315  

Get-Help Get-VM

Get-Member Get-VM | Get-Member  

Page 18: Automation using power cli

Addi'onal  Info  

•  Local  Resources  – h9p://vmwarescrip'ng.com  

– h9p://wannemacher.us  

•  Other  – Managing  VMware  Infrastructure  with  Windows  PowerShell  TFM  

– The  VMware  Community  Forums  (LucD)  – Google