introduction to managing vmware with powershell
DESCRIPTION
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.aspTRANSCRIPT
![Page 1: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/1.jpg)
Hal Rottenberg [email protected]
![Page 2: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/2.jpg)
Hal Rottenberg [email protected] Over 12 years in the IT industry; everything
from helpdesk, to sysadmin, to technical consultant
Author, Managing VMware Infrastructure with PowerShell: TFM from Sapien Press (due out “as soon as he can possibly get it done”)
Community Director, PowerShellCommunity.org
Co-Host, PowerScripting Podcast (powerscripting.net)
Blog Author, TechProsaic (halr9000.com)
![Page 3: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/3.jpg)
IntroductionFeature overviewDemo 1: new providersNew CmdletsDemo 2: “wiki deploy”Demo 3: Creating a VMDemo 4: Access VI SDK
![Page 4: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/4.jpg)
Programming API Web service (WSDL) Samples included for Java, C, C# Low level
Scripting API Perl and COM interfaces available Wrapper for web services
![Page 5: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/5.jpg)
You still must learn the VI SDK
Higher level than SDK, but not by much
Perl interface not familiar to Windows admins
COM interface was not very popular, hard to find examples
![Page 6: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/6.jpg)
PowerShell snap-in Client-side “automation objects”
correspond to server-side “managed objects” and “managed entities”
Not just a web service wrapper Favors action-oriented cmdlets over
object methods Goal: 80% of tasks will not require SDK Ability to access the SDK for more
complex tasks
![Page 7: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/7.jpg)
Fully supported: Virtual Center 2.x ESX Server 3.x (including 3i)
Unofficially supported: VMware Server 2.0 beta
Works with PowerShell v1 or v2 CTP
![Page 8: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/8.jpg)
Includes over 120 cmdletsCount 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}
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}
![Page 9: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/9.jpg)
Also includes two PSProviders Remote filesystem (datastore) access via
VimDatastore provider Hierarchical management of Folders,
Datacenters, VMHosts, VMs using VimInventory provider
Name Capabilities Drives---- ------------ ------VimDatastore Filter, ShouldProcess {DS}VimInventory Filter {VI}
Name Capabilities Drives---- ------------ ------VimDatastore Filter, ShouldProcess {DS}VimInventory Filter {VI}
![Page 10: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/10.jpg)
VimInventoryVimDatastore
New-PSDrive -Name VI -PSProvider VimInventory ` -Root '/' -location (Get-Folder -NoRecursion)New-PSDrive -Name DS -PSProvider VimDatastore ` -Root '/' -location (Get-Datastore $DatastoreName)
New-PSDrive -Name VI -PSProvider VimInventory ` -Root '/' -location (Get-Folder -NoRecursion)New-PSDrive -Name DS -PSProvider VimDatastore ` -Root '/' -location (Get-Datastore $DatastoreName)
EXPERIMENTAL!
![Page 11: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/11.jpg)
![Page 12: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/12.jpg)
PS > Get-VM
Name PowerState Num CPUs Memory (MB)---- ---------- -------- -----------SDK-RHAS4U4 PoweredOff 1 512SDK-W2003ENT PoweredOff 1 256fudgeapp01 PoweredOff 1 256fudgedb01 PoweredOff 1 512vcenter.halr9000.com PoweredOn 2 1500fudgedb02 PoweredOff 1 1024SDK-XPSP2 PoweredOff 1 256
PS > Get-VM
Name PowerState Num CPUs Memory (MB)---- ---------- -------- -----------SDK-RHAS4U4 PoweredOff 1 512SDK-W2003ENT PoweredOff 1 256fudgeapp01 PoweredOff 1 256fudgedb01 PoweredOff 1 512vcenter.halr9000.com PoweredOn 2 1500fudgedb02 PoweredOff 1 1024SDK-XPSP2 PoweredOff 1 256
PS > Get-VMHost
Name State Id---- ----- --192.168.0.51 Connected HostSys...192.168.0.55 Connected HostSys...
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.ConnectInfoImplID : VirtualMachine-vm-158/3000Name : CD/DVD Drive 1
PS > Get-VM vcenter.halr9000.com | Get-CDDrive
ISOPath :HostDevice :RemoteDevice :ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImplID : VirtualMachine-vm-158/3000Name : CD/DVD Drive 1
PS > Get-Cluster "test cluster" | fl
HAEnabled : FalseHAAdmissionControlEnabled : FalseHAFailoverLevel : 1DRSEnabled : FalseDRSMode : FullyAutomatedCustomFields : {}ID : ClusterComputeResource-domain-c449Name : Test Cluster
PS > Get-Cluster "test cluster" | fl
HAEnabled : FalseHAAdmissionControlEnabled : FalseHAFailoverLevel : 1DRSEnabled : FalseDRSMode : FullyAutomatedCustomFields : {}ID : ClusterComputeResource-domain-c449Name : Test Cluster
Get-VM Get-VMHost Get-CDDrive Get-Cluster
![Page 13: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/13.jpg)
New-Datacenter New-Cluster Add-VMHost New-VM
![Page 14: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/14.jpg)
Create folders “wiki-style”
![Page 15: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/15.jpg)
Cmdlets used: New-VM
![Page 16: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/16.jpg)
Remove-SnapshotMove-VMSet-NetworkAdapterRestart-VMGuest
![Page 17: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/17.jpg)
Cmdlets used: New-Snapshot
![Page 18: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/18.jpg)
get-vm MYSERVER | move-vm -dest (get-vmhost ESX2)
get-cluster TEST | get-vm | move-vm –dest (get-cluster PRODUCTION)
![Page 19: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/19.jpg)
![Page 20: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/20.jpg)
Get-VIEventGet-TaskGet-LogGet-Stat
![Page 21: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/21.jpg)
Cmdlets used: Get-VIEvent
![Page 22: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/22.jpg)
When the simplified interface doesn’t cut it…you can always work with the SDK
Cmdlets used Get-View
ISCSI Configuration
![Page 23: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/23.jpg)
![Page 24: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/24.jpg)
VI Toolkit: http://vmware.com/go/powershell VI Toolkit blog:
http://blogs.vmware.com/vipowershell/ VI Toolkit Community:
http://communities.vmware.com/community/developer/windows_toolkit
PowerShellCommunity.org: http://powershellcommunity.org
PowerScripting Podcast: http://powerscripting.net
Managing VI with PowerShell: TFM: http://sapienpress.com/vmware.asp
Hal’s Blog: http://halr9000.com
![Page 25: Introduction To Managing VMware With PowerShell](https://reader034.vdocument.in/reader034/viewer/2022051209/5481be4ab4af9fb9018b47ae/html5/thumbnails/25.jpg)