Managing VMware with PowerShell - VMworld 2008

24
Disclaim er This session may contain product features that are currently under development. This session/overview of the new technology represents no commitment from VMware to deliver these features in any generally available product. Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery. Pricing and packaging for any new technologies or features discussed or presented have not been determined. “These features are representative of feature areas under development. Feature commitments are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery.”

description

This is the slide deck I used during my talk "Managing VMware with PowerShell" at VMworld 2008. Some video snippets of the presentation are also available at http://communities.vmware.com/thread/169066

Transcript of Managing VMware with PowerShell - VMworld 2008

Page 1: Managing VMware with PowerShell - VMworld 2008

Disclaimer

This session may contain product features that are currently under development.

This session/overview of the new technology represents no commitment from VMware to deliver these features in any generally available product.

Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind.

Technical feasibility and market demand will affect final delivery.

Pricing and packaging for any new technologies or features discussed or presented have not been determined.

“These features are representative of feature areas under development. Feature commitments are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery.”

Page 2: Managing VMware with PowerShell - VMworld 2008

Managing VMware With PowerShell

Carter Shanklin – Product Manager, VMware

Andrey Anastasov – PowerShell Architect, VMware

Dmitry Sotnikov – Manager and Microsoft MVP,

Quest Software

Page 3: Managing VMware with PowerShell - VMworld 2008

My goal today is simple.

Convince you that

any serious VMware admin

MUST knowthe VI Toolkit for Windows.

Page 4: Managing VMware with PowerShell - VMworld 2008

Not convinced?

To prove this I will:

Introduce The VI Toolkit for Windows.

Show you the top 3 ways the Toolkit makes your life easier.

Show you lots of samples as well as the resources available.

Demonstrate how PowerGUI can help you get started.

Tell you how to get the toolkit so you can get started today.

Page 5: Managing VMware with PowerShell - VMworld 2008

Introducing The VI Toolkit (for Windows).

The VI Toolkit for Windows simplifies large-scale management.

Get a handle on VM sprawl or out-of-control snapshots through automation.

It’s a scripting tool, based on PowerShell.

It’s easy to use.

Many useful actions require 0 scripting.

It provides 125 powerful cmdlets.

Covers all aspects of Virtual Infrastructure management.

It’s completely FREE!

Page 6: Managing VMware with PowerShell - VMworld 2008

What is PowerShell?

PowerShell is Microsoft’s new foundation for management.

PowerShell support is required for all Microsoft Server apps.

Manages different applications in a consistent way.

Chances are, you are learning it or planning to learn it.

Page 7: Managing VMware with PowerShell - VMworld 2008

What does PowerShell look like?

PowerShell is centered around cmdlets. Cmdlets are provided to do all sorts of tasks. More cmdlets can be added with 3rd party snapins. Cmdlets can be strung together using pipelines.

PowerShell cmdlets use common conventions. Cmdlets follow the Verb-Noun convention.

Example: Get-Process.

This tends to lead to commands that follow our thinking. Example: Get-Process notepad | Stop-Process

PowerShell is object-oriented. No more text parsing!

Page 8: Managing VMware with PowerShell - VMworld 2008

Top 3 ways your life gets better 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.

Page 9: Managing VMware with PowerShell - VMworld 2008

Disconnect CD-ROM and floppy drives to enable VMotion.

PowerShell:

2 Commands

Full Automation

Manually:

1 Minute / VM

BORING!

Automate Repetitive Tasks.

Page 10: Managing VMware with PowerShell - VMworld 2008

Cloning a VM many times can take forever.

PowerShell:

As little as 1 command

Full Automation

Manually:

10 Min+ / VM

BORING!

Save time: Attack of the clones.

Page 11: Managing VMware with PowerShell - VMworld 2008

A customer needed to create secondary service consoles on 400+ hosts.

PowerShell:

Automated, with

forum support.

Manually:

400 Hosts

20+ Hours

The story you are about to witness is real.

Page 12: Managing VMware with PowerShell - VMworld 2008

A tour of the toolkit.

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

125 cmdlets in total.

Page 13: Managing VMware with PowerShell - VMworld 2008

VI Toolkit types tag cloud.

The focus is on VM and ESX Management,

But you can manage all aspects of VI with the toolkit.

Page 14: Managing VMware with PowerShell - VMworld 2008

Incredibly Powerful Examples:

Snapshot every VM you have:

Get-VM | New-Snapshot –Name “New Snapshot”

Find all snapshots older than 1 month:

Get-VM | Get-Snapshot |

Where { $_.Created –lt (Get-Date).addMonths(-1) }

Change every VM on Network A to Network B:

Get-VM | Get-NetworkAdapter |

where { $_.NetworkName –eq “Network A” } |

Set-NetworkAdapter –NetworkName B

Page 15: Managing VMware with PowerShell - VMworld 2008

More Incredibly Powerful Examples:

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

Restart an unresponsive VirtualCenter agent:

Get-VMHost badhost | Get-VMHostService |

Where { $_.key –eq “vmware-vpxa” } |

Restart-VMHostService

Page 16: Managing VMware with PowerShell - VMworld 2008

As if that weren’t enough!

Rescan every HBA on all hosts:

Get-VMHost | Get-VMHostStorage -RescanAllHba

Ensure your VMs will all start after ESX is restarted:

Get-VMHostStartPolicy |Set-VMHostStartPolicy -enabled:$true

Get-VM | Get-VMStartPolicy |

Set-VMStartPolicy -StartAction poweron

Move every VM on host A to host B:

Get-VMHost A | Get-VM |

Move-VM –destination (Get-VMHost B)

Page 17: Managing VMware with PowerShell - VMworld 2008

A Tour of Available Resources.

The VI Toolkit (for Windows) Community.

A very active community with lots of very smart people.

Over 300 examples to guide you.

The VI Toolkit (for Windows) FAQ.

40 frequently asked questions with answers.

Plenty of sample code.

The VI Toolkit (for Windows) Blog.

Lots of examples and ideas.

Updated regularly.

All available from http://vmware.com/go/powershell

Page 18: Managing VMware with PowerShell - VMworld 2008

Announcing The VI Toolkit Community Extensions.

The VI Toolkit Community Extensions:

A module that can be loaded into your scripts.

Open source.

A way for us to make all of the good ideas in our forums more accessible.

Uses scripts so everyone can contribute.

A “first line” for new functionality.

Download it at http://codeplex.com/vitoolkitextensions

Page 19: Managing VMware with PowerShell - VMworld 2008

What can you learn through these resources?

Among other things you can learn to:

Change the VMware tools upgrade policy.

List all storage world wide names.

Register unregistered VMs.

Create reports.

Customize VM hardware.

Remotely power ESX hosts on and off.

Configure NTP.

Execute scripts in response to VirtualCenter alarms.

Much, much more!

Page 20: Managing VMware with PowerShell - VMworld 2008

What to expect in the future.

Even better VI management.

We’ll continue to make the VI admin’s life easy.

Support for more VMware products.

Products that complement and extend VMware VI.

Improved VMware PowerShell Community Extensions.

This will hold a large library of cmdlets of all different types.

Share your own ideas and help us build this community.

Page 21: Managing VMware with PowerShell - VMworld 2008

Don’t be a script-o-phobe!

PowerGUI Script Editor makes writing scripts easy.

Syntax highlighting.

Name completion.

PowerGUI Admin Console generates code for you!

No more “I’ve been meaning to get around to it”.

Page 22: Managing VMware with PowerShell - VMworld 2008

DEMO

Page 23: Managing VMware with PowerShell - VMworld 2008

Convinced? Get the toolkit today!

http://vmware.com/go/powershell

Page 24: Managing VMware with PowerShell - VMworld 2008

Q&A

Breakout Session #AD2764

Carter Shanklin Additional InformationProduct Manager, VMware Inc. http://vmware.com/go/powershell9/16/2008