Introduction To Managing VMware With PowerShell

4,379 views

Published on

Introduction to the VI Toolkit which is available at http://vmware.com/go/powershell. Companion to my book which is at http://sapienpress.com/vmware.asp

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,379
On SlideShare
0
From Embeds
0
Number of Embeds
36
Actions
Shares
0
Downloads
176
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Introduction To Managing VMware With PowerShell

  1. 1. Hal Rottenberg [email_address]
  2. 2. <ul><li>Hal Rottenberg [email_address] </li></ul><ul><ul><li>Over 12 years in the IT industry; everything from helpdesk, to sysadmin, to technical consultant </li></ul></ul><ul><ul><li>Author, Managing VMware Infrastructure with PowerShell: TFM from Sapien Press (due out “as soon as he can possibly get it done”) </li></ul></ul><ul><ul><li>Community Director, PowerShellCommunity.org </li></ul></ul><ul><ul><li>Co-Host, PowerScripting Podcast (powerscripting.net) </li></ul></ul><ul><ul><li>Blog Author, TechProsaic (halr9000.com) </li></ul></ul>
  3. 3. <ul><li>Introduction </li></ul><ul><li>Feature overview </li></ul><ul><li>Demo 1: new providers </li></ul><ul><li>New Cmdlets </li></ul><ul><li>Demo 2: “wiki deploy” </li></ul><ul><li>Demo 3: Creating a VM </li></ul><ul><li>Demo 4: Access VI SDK </li></ul>
  4. 4. <ul><li>Programming API </li></ul><ul><ul><li>Web service (WSDL) </li></ul></ul><ul><ul><li>Samples included for Java, C, C# </li></ul></ul><ul><ul><li>Low level </li></ul></ul><ul><li>Scripting API </li></ul><ul><ul><li>Perl and COM interfaces available </li></ul></ul><ul><ul><li>Wrapper for web services </li></ul></ul>
  5. 5. <ul><li>You still must learn the VI SDK </li></ul><ul><li>Higher level than SDK, but not by much </li></ul><ul><li>Perl interface not familiar to Windows admins </li></ul><ul><li>COM interface was not very popular, hard to find examples </li></ul>
  6. 6. <ul><li>PowerShell snap-in </li></ul><ul><li>Client-side “automation objects” correspond to server-side “managed objects” and “managed entities” </li></ul><ul><li>Not just a web service wrapper </li></ul><ul><li>Favors action-oriented cmdlets over object methods </li></ul><ul><li>Goal: 80% of tasks will not require SDK </li></ul><ul><li>Ability to access the SDK for more complex tasks </li></ul>
  7. 7. <ul><li>Fully supported: </li></ul><ul><ul><li>Virtual Center 2.x </li></ul></ul><ul><ul><li>ESX Server 3.x (including 3i) </li></ul></ul><ul><li>Unofficially supported: </li></ul><ul><ul><li>VMware Server 2.0 beta </li></ul></ul><ul><li>Works with PowerShell v1 or v2 CTP </li></ul>
  8. 8. <ul><li>Includes over 120 cmdlets </li></ul>Count Name Group ----- ---- ----- 1 Add {Add-VMHost} 1 Connect {Connect-VIServer} 1 Disconnect {Disconnect-VIServer} 1 Dismount {Dismount-Tools} 37 Get {Get-CDDrive, Get-Cluster, Get-Datacenter,... 1 Mount {Mount-Tools} 7 Move {Move-Cluster, Move-Datacenter, Move-Folde... 19 New {New-CDDrive, New-Cluster, New-CustomField... 20 Remove {Remove-CDDrive, Remove-Cluster, Remove-Cu... 2 Restart {Restart-VMGuest, Restart-VMHostService} 27 Set {Set-CDDrive, Set-Cluster, Set-CustomField... 1 Shutdown {Shutdown-VMGuest} 2 Start {Start-VM, Start-VMHostService} 3 Stop {Stop-Task, Stop-VM, Stop-VMHostService} 2 Suspend {Suspend-VM, Suspend-VMGuest} 1 Test {Test-VMHostSNMP} 1 Update {Update-Tools} 1 Wait {Wait-Task}
  9. 9. <ul><li>Also includes two PSProviders </li></ul><ul><ul><li>Remote filesystem (datastore) access via VimDatastore provider </li></ul></ul><ul><ul><li>Hierarchical management of Folders, Datacenters, VMHosts, VMs using VimInventory provider </li></ul></ul>Name Capabilities Drives ---- ------------ ------ VimDatastore Filter, ShouldProcess {DS} VimInventory Filter {VI}
  10. 10. <ul><li>VimInventory </li></ul><ul><li>VimDatastore </li></ul><ul><ul><li>New-PSDrive -Name VI -PSProvider VimInventory ` </li></ul></ul><ul><ul><li>-Root '/' -location (Get-Folder -NoRecursion) </li></ul></ul><ul><ul><li>New-PSDrive -Name DS -PSProvider VimDatastore ` </li></ul></ul><ul><ul><li>-Root '/' -location (Get-Datastore $DatastoreName) </li></ul></ul>EXPERIMENTAL!
  11. 12. <ul><ul><li>Get-VM </li></ul></ul><ul><ul><li>Get-VMHost </li></ul></ul><ul><ul><li>Get-CDDrive </li></ul></ul><ul><ul><li>Get-Cluster </li></ul></ul>PS > Get-VM Name PowerState Num CPUs Memory (MB) ---- ---------- -------- ----------- SDK-RHAS4U4 PoweredOff 1 512 SDK-W2003ENT PoweredOff 1 256 fudgeapp01 PoweredOff 1 256 fudgedb01 PoweredOff 1 512 vcenter.halr9000.com PoweredOn 2 1500 fudgedb02 PoweredOff 1 1024 SDK-XPSP2 PoweredOff 1 256 PS > Get-VMHost Name State Id ---- ----- -- 192.168.0.51 Connected HostSys... 192.168.0.55 Connected HostSys... PS > Get-VM vcenter.halr9000.com | Get-CDDrive ISOPath : HostDevice : RemoteDevice : ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl ID : VirtualMachine-vm-158/3000 Name : CD/DVD Drive 1 PS > Get-Cluster &quot;test cluster&quot; | fl HAEnabled : False HAAdmissionControlEnabled : False HAFailoverLevel : 1 DRSEnabled : False DRSMode : FullyAutomated CustomFields : {} ID : ClusterComputeResource-domain-c449 Name : Test Cluster
  12. 13. <ul><li>New-Datacenter </li></ul><ul><li>New-Cluster </li></ul><ul><li>Add-VMHost </li></ul><ul><li>New-VM </li></ul>
  13. 14. <ul><li>Create folders “wiki-style” </li></ul>
  14. 15. <ul><li>Cmdlets used: </li></ul><ul><ul><li>New-VM </li></ul></ul>
  15. 16. <ul><li>Remove-Snapshot </li></ul><ul><li>Move-VM </li></ul><ul><li>Set-NetworkAdapter </li></ul><ul><li>Restart-VMGuest </li></ul>
  16. 17. <ul><li>Cmdlets used: </li></ul><ul><ul><li>New-Snapshot </li></ul></ul>
  17. 18. <ul><li>get-vm MYSERVER | move-vm -dest (get-vmhost ESX2) </li></ul><ul><li>get-cluster TEST | get-vm | move-vm –dest (get-cluster PRODUCTION) </li></ul>
  18. 20. <ul><li>Get-VIEvent </li></ul><ul><li>Get-Task </li></ul><ul><li>Get-Log </li></ul><ul><li>Get-Stat </li></ul>
  19. 21. <ul><li>Cmdlets used: </li></ul><ul><ul><li>Get-VIEvent </li></ul></ul>
  20. 22. <ul><li>When the simplified interface doesn’t cut it…you can always work with the SDK </li></ul><ul><li>Cmdlets used </li></ul><ul><ul><li>Get-View </li></ul></ul><ul><li>ISCSI Configuration </li></ul>
  21. 24. <ul><li>VI Toolkit: http://vmware.com/go/powershell </li></ul><ul><li>VI Toolkit blog: http://blogs.vmware.com/vipowershell/ </li></ul><ul><li>VI Toolkit Community: http://communities.vmware.com/community/developer/windows_toolkit </li></ul><ul><li>PowerShellCommunity.org: http://powershellcommunity.org </li></ul><ul><li>PowerScripting Podcast: http://powerscripting.net </li></ul><ul><li>Managing VI with PowerShell: TFM: http://sapienpress.com/vmware.asp </li></ul><ul><li>Hal’s Blog: http://halr9000.com </li></ul>

×