Successfully reported this slideshow.
Your SlideShare is downloading. ×

Managing VMware With PowerShell

Loading in …3

Check these out next

1 of 30 Ad

More Related Content

Viewers also liked (20)


Recently uploaded (20)

Managing VMware With PowerShell

  1. 1. Managing VMware Infrastructure with VI Toolkit (for Windows) Carter Shanklin VMware Infrastructure Product Manager VMware
  2. 2. Overview <ul><ul><li>What is the VI Toolkit (for Windows) </li></ul></ul><ul><ul><li>The top 3 ways your life gets easier with the toolkit </li></ul></ul><ul><ul><li>Interactive demos </li></ul></ul><ul><ul><li>Resources to help you use the toolkit </li></ul></ul><ul><ul><li>How to get the toolkit </li></ul></ul>
  3. 3. What is the VI Toolkit (for Windows)? <ul><ul><li>The VI Toolkit is a platform for the automation of administrative tasks. </li></ul></ul><ul><ul><ul><li>Remotely manage and automate VI. </li></ul></ul></ul><ul><ul><li>The VI Toolkit is easy to use. </li></ul></ul><ul><ul><ul><li>The commands are designed from the ground for ease of use. </li></ul></ul></ul><ul><ul><ul><li>You don’t have to be a developer. </li></ul></ul></ul><ul><ul><ul><li>Many useful tasks can be accomplished with only a couple of commands. </li></ul></ul></ul><ul><ul><li>Based on PowerShell. </li></ul></ul><ul><ul><ul><li>If you are a Windows admin, you either know some PowerShell or plan to learn it. </li></ul></ul></ul>
  4. 4. What is PowerShell? <ul><ul><li>PowerShell is Microsoft’s foundation for automation. </li></ul></ul><ul><ul><ul><li>Starting in 2008, all Microsoft enterprise software must enable automation through PowerShell. </li></ul></ul></ul><ul><ul><ul><li>Other vendors are adopting the same approach. </li></ul></ul></ul><ul><ul><ul><li>PowerShell lets you manage different applications in a consistent way. </li></ul></ul></ul>
  5. 5. Top 3 Ways Your Life is Easier with the Toolkit <ul><ul><li>Save time by automating repetitive tasks. 100 is just as easy as 1. </li></ul></ul><ul><ul><li>Automate time consuming tasks for greater productivity. Let your scripts do the waiting. </li></ul></ul><ul><ul><li>Turn questions into answers with our large and growing set of online resources. </li></ul></ul>
  6. 6. <ul><li>Disconnect CD-ROM and floppy drives to enable VMotion. </li></ul>Automate Repetitive Tasks PowerShell: 2 Commands Full Automation Manually: 1 Minute / VM BORING!
  7. 7. Automate Lengthy Tasks For Greater Productivity Manually: 10 Minutes per VM PowerShell: 1 Command Full Automation
  8. 8. You’ve Got Questions, We’ve Got Answers <ul><ul><li>With the help of our forums, our users have: </li></ul></ul><ul><ul><ul><li>Deployed more than 200 VMs from a template. </li></ul></ul></ul><ul><ul><ul><li>Configured VMware tools to automatically upgrade on all VMs. </li></ul></ul></ul><ul><ul><ul><li>Load balance from their ESX systems to their storage arrays. </li></ul></ul></ul><ul><ul><ul><li>Changed the video memory on 2,000 virtual desktops. </li></ul></ul></ul><ul><ul><ul><li>Created custom reports. </li></ul></ul></ul><ul><ul><ul><li>And much more! </li></ul></ul></ul>
  9. 9. A Tour Of Windows PowerShell <ul><ul><li>PowerShell comes with over 100 commands called cmdlets, and extensive documentation. </li></ul></ul><ul><ul><li>PowerShell has syntax conventions. </li></ul></ul><ul><ul><ul><li>Verb-Noun. </li></ul></ul></ul><ul><ul><ul><li>Fosters a common look and feel across applications. </li></ul></ul></ul><ul><ul><li>PowerShell supports discoverability. </li></ul></ul><ul><ul><ul><li>The Get-Member cmdlets lets you see what is possible with objects. </li></ul></ul></ul><ul><ul><li>PowerShell also provides access to all of .NET, COM and WMI. </li></ul></ul>
  10. 10. A Tour of The VI Toolkit (for Windows) <ul><ul><li>get-vicommand – shows all 125 commands. </li></ul></ul><ul><ul><li>VM Lifecycle: </li></ul></ul><ul><ul><ul><li>New-VM, Start-VM, Set-VM </li></ul></ul></ul><ul><ul><li>Snapshots: </li></ul></ul><ul><ul><ul><li>Get-Snapshot, New-Snapshot, Set-VM </li></ul></ul></ul><ul><ul><li>Templates and Customization Specs: </li></ul></ul><ul><ul><ul><li>New-Template, New-OSCustomizationSpec, New-VM </li></ul></ul></ul><ul><ul><li>Virtual Switches: </li></ul></ul><ul><ul><ul><li>New-VirtualSwitch, New-VirtualPortGroup, Set-VirtualSwitch </li></ul></ul></ul><ul><ul><li>Performance Statistics and Monitoring: </li></ul></ul><ul><ul><ul><li>Get-Stat </li></ul></ul></ul>
  11. 11. More than Just Virtual Infrastructure <ul><ul><li>The VI Toolkit (for Windows) provides 125 cmdlets for VI. </li></ul></ul><ul><ul><li>VMware Update Manager provides 13 cmdlets to help you automate keeping your VI up-to-date. </li></ul></ul><ul><ul><li>Features: </li></ul></ul><ul><ul><ul><li>Download updates. </li></ul></ul></ul><ul><ul><ul><li>Manipulate baselines. </li></ul></ul></ul><ul><ul><ul><li>Remediate. </li></ul></ul></ul><ul><ul><ul><li>Even more! </li></ul></ul></ul>
  12. 12. Demos
  13. 13. Demos: Snapshots <ul><ul><li>Snapshot every powered-on VM: </li></ul></ul><ul><ul><li>Get-VM | Where { $_.PowerState –eq “PoweredOn” } | </li></ul></ul><ul><ul><li>New-Snapshot –Name “New Snapshot” </li></ul></ul><ul><ul><li>Delete all of those snapshots: </li></ul></ul><ul><ul><li>Get-VM | Get-Snapshot | </li></ul></ul><ul><ul><li>Where { $_.Name –eq “New Snapshot” } | </li></ul></ul><ul><ul><li>Remove-Snapshot </li></ul></ul><ul><ul><li>Find all snapshots older than 1 month: </li></ul></ul><ul><ul><li>Get-VM | Get-Snapshot | </li></ul></ul><ul><ul><li>Where { $_.Created –lt (Get-Date).addMonths(-1) } </li></ul></ul>
  14. 14. Demos: Networking <ul><ul><li>Move every VM on Network “Provisioning” to Network “Production” </li></ul></ul><ul><ul><li>Get-VM | Get-NetworkAdapter | </li></ul></ul><ul><ul><li>Where { $_.NetworkName –eq “Provisioning” } | </li></ul></ul><ul><ul><li>Set-NetworkAdapter –NetworkName “Production” </li></ul></ul><ul><ul><li>Create a virtual switch on interface vmnic1 </li></ul></ul><ul><ul><li>Get-VMHost | New-VirtualSwitch –name “Second Switch” ` </li></ul></ul><ul><ul><li>-nic vmnic1 </li></ul></ul><ul><ul><li>Configure a new VMKernel on these new switches for management and VMotion. </li></ul></ul><ul><ul><li>Get-VMHost | New-VMHostNetworkAdapter ` </li></ul></ul><ul><ul><li>-virtualswitch (get-virtualswitch -name “Second Switch”) ` </li></ul></ul><ul><ul><li>-vmotionenabled:$true -portgroup blah2 -ip ` </li></ul></ul><ul><ul><li>– subnetmask </li></ul></ul>
  15. 15. Demos: Configuration Management <ul><ul><li>Ensure all your VMs have at least 1GB of RAM: </li></ul></ul><ul><ul><li>Get-VM | Where { $_.MemoryMB –lt 1024 } | </li></ul></ul><ul><ul><li>Set-VM –MemoryMB 1024 </li></ul></ul><ul><ul><li>Update VMware Tools in every VM in the “Americas 1” datacenter: </li></ul></ul><ul><ul><li>Get-Datacenter “Americas 1” | Get-VM | Update-Tools </li></ul></ul>
  16. 16. Demos: Storage <ul><ul><li>Rescan every HBA on all hosts: </li></ul></ul><ul><ul><li>Get-VMHost | Get-VMHostStorage -RescanAllHba </li></ul></ul><ul><ul><li>Create new datastores: </li></ul></ul><ul><ul><ul><li>NFS: </li></ul></ul></ul><ul><ul><ul><ul><li>Get-VMHost | </li></ul></ul></ul></ul><ul><ul><ul><ul><li>New-Datastore –Nfs –NfsHost myserver –name “New Datastore” </li></ul></ul></ul></ul><ul><ul><ul><li>FC / iSCSI: </li></ul></ul></ul><ul><ul><ul><ul><li>Note: In the 1.0 toolkit you’ll need to retreive SCSI Luns using the Host’s StorageSystem. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Get-VMHost | </li></ul></ul></ul></ul><ul><ul><ul><ul><li>New-Datastore -Vmfs -Path $lunpath.LunPath ` </li></ul></ul></ul></ul><ul><ul><ul><ul><li>– Name “New Datastore” </li></ul></ul></ul></ul>
  17. 17. Demos: Reporting <ul><ul><li>Determine statistics about VM disk usage: </li></ul></ul><ul><ul><ul><li>( get-vm | foreach { ($_ | get-harddisk | measure-object -property CapacityKB -sum).Sum } ) | measure-object -average -sum -maximum –minimum </li></ul></ul></ul><ul><ul><li>Sort hosts by number of VMs hosted: </li></ul></ul><ul><ul><ul><li>get-vm | select name, @{ Name=&quot;Host&quot;; Expression={$} } | group Host | select name, count | sort count </li></ul></ul></ul><ul><ul><li>Sort hosts by CPU utilized in the past 45 minutes: </li></ul></ul><ul><ul><ul><li>get-vmhost | select Name, @{Name=&quot;Average CPU Usage (%)&quot;; Expression={ ($_ | get-stat | where { $_.MetricId -eq &quot;cpu.usage.average&quot; } | measure-object -property Value -average | select average).average } } | sort </li></ul></ul></ul>
  18. 18. A Tour of Available Resources <ul><ul><li>Many resources are available to support automation and give you ideas about what can be done. </li></ul></ul><ul><ul><ul><li>The PowerShell forum. </li></ul></ul></ul><ul><ul><ul><li>The FAQ. </li></ul></ul></ul><ul><ul><ul><li>The PowerShell blog. </li></ul></ul></ul>
  19. 19. The PowerShell Forum <ul><ul><li> </li></ul></ul><ul><ul><li>People in the forum have found support for things like: </li></ul></ul><ul><ul><ul><li>Clone templates. </li></ul></ul></ul><ul><ul><ul><li>Mask CPU features to enable VMotion. </li></ul></ul></ul><ul><ul><ul><li>Make firewall configuration changes. </li></ul></ul></ul><ul><ul><ul><li>Configure HA and DRS. </li></ul></ul></ul><ul><ul><ul><li>Much, much more. </li></ul></ul></ul>
  20. 20. From the Forum <ul><ul><li>Changing the boot order of VMs. </li></ul></ul><ul><ul><ul><li>Sometimes the BIOS boot order of a VM needs to be changed. </li></ul></ul></ul><ul><ul><ul><li>The solution (from LucD in the PowerShell Forum): </li></ul></ul></ul>$spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.extraConfig += New-Object VMware.Vim.OptionValue $spec.extraConfig[0].key = &quot;bios.bootDeviceClasses&quot; $spec.extraConfig[0].value = &quot;allow:cd,hd&quot; get-vm | % { (get-view $_.ID).ReconfigVM_Task($spec) }
  21. 21. The PowerShell FAQ <ul><ul><li> . </li></ul></ul><ul><ul><li>Contains 25 frequently asked questions about using PowerShell to manage VI. </li></ul></ul><ul><ul><li>Examples: </li></ul></ul><ul><ul><ul><li>Creating VMs on particular datastores. </li></ul></ul></ul><ul><ul><ul><li>Setting resource levels on all VMs. </li></ul></ul></ul><ul><ul><ul><li>Snapshotting multiple VMs. </li></ul></ul></ul>
  22. 22. From the FAQ <ul><ul><li>Setting resource levels on VMs. </li></ul></ul><ul><ul><ul><li>VC upgrades may reset custom resource levels. </li></ul></ul></ul><ul><ul><ul><li>The solution: </li></ul></ul></ul>Get-VM | % { $view = Get-View $_.ID $spec = new-object VMware.Vim.VirtualMachineConfigSpec $spec.CPUAllocation = New-Object VMware.Vim.ResourceAllocationInfo $spec.CpuAllocation.Shares = New-Object VMware.Vim.SharesInfo $spec.CpuAllocation.Shares.Level = &quot;normal&quot; $spec.CpuAllocation.Limit = -1 $view.ReconfigVM_Task($spec) }
  23. 23. The PowerShell Blog <ul><ul><li>http:// / </li></ul></ul><ul><ul><li>Contains periodic ideas and resources for making VI management easier and more effective. </li></ul></ul>Jonathan Walz and Hal Rottenberg have an excellent podcast that is devoted to Windows PowerShell, if you haven’t listened you should definitely give it a try.
  24. 24. From the Blog <ul><ul><li>Configuring storage paths. </li></ul></ul><ul><ul><ul><li>Configuring storage paths is an important step for performance optimization. </li></ul></ul></ul><ul><ul><ul><li>Configuring this manually is usually not practical. </li></ul></ul></ul><ul><ul><ul><li>The blog gives examples of how to do it. </li></ul></ul></ul><ul><ul><ul><li>Example: Enabling round-robin multipathing on all hosts. </li></ul></ul></ul>
  25. 25. That’s Not All! <ul><ul><li>PowerShell has an extensive set of 3 rd party tools to help you do your own integrations. </li></ul></ul>Tool Name Features Offered PowerGUI Graphical PowerShell frontend PowerGadgets Visual dashboards and reports NetCmdlets Provides network access (e.g. ssh) Quest AD Cmdlets Manage Microsoft Active Directory SpecOps Software Execute PowerShell using group policy
  26. 26. 3 rd Party Tools: PowerGUI <ul><ul><li>PowerGUI is a graphical interface to PowerShell. </li></ul></ul><ul><ul><ul><li>Easy administration using the MMC-like PowerGUI Admin Editor. </li></ul></ul></ul><ul><ul><ul><li>Easy script editing with the PowerGUI Script Editor. </li></ul></ul></ul><ul><ul><ul><li>Automatically generate PowerShell code with the PowerGUI Admin Editor. </li></ul></ul></ul>
  27. 27. 3 rd Party Tools: PowerGadgets
  28. 28. Are You a PowerShell Scripting Guru? <ul><li>Enter PowerShell Scripting Contest </li></ul><ul><ul><li>Win great prizes, show off your scripting skills </li></ul></ul><ul><ul><li>First Prize: Free Trip to VMworld – Las Vegas or $5,000 </li></ul></ul><ul><ul><li>Second Prize: Mac Air w/ Fusion or $2500 </li></ul></ul><ul><ul><li>Third Prize: Xbox Elite or $500 Cash </li></ul></ul><ul><ul><li>Contest Ends August 30 th , 2008 </li></ul></ul><ul><ul><li>Winner Announced September 7, 2008 </li></ul></ul><ul><ul><li>For more information: </li></ul></ul><ul><ul><li>http:// </li></ul></ul>
  29. 29. Questions? Please use the Q&A panel of your WebEx console For more Webcast information, please visit This Webcast has been recorded, and the slides will be ready for download within 48 hours. Once the presentation is available, an e-mail will be sent to you with directions on how to access the recorded version.

Editor's Notes