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