PowerCLI Workshop

200
vSphere PowerCLI The best tool for automating vSphere http://vmware.com/go/powerc

description

v1 of my PowerCLI Workshop. Download the scripts at http://communities.vmware.com/docs/DOC-12014

Transcript of PowerCLI Workshop

Page 1: PowerCLI Workshop

vSphere PowerCLIThe best tool for automating vSphere

http://vmware.com/go/powercli

Page 2: PowerCLI Workshop

Introduction. About me.

Product Manager – APIs and platform.twitter.com/cshanklin (@cshanklin)

Did you know?Most of the world’s top virtualization

experts use twitter?

http://vmware.com/go/powercli

Page 3: PowerCLI Workshop

The Purpose of PowerCLI.

PowerCLI is a tool for automating all aspects of vSphere management and administration.

But PowerCLI is different because it’s purpose-built for use by administrators, not developers.

“Any knowledgeable vSphere administrator can look at PowerCLI code and immediately understand what it does.”

http://vmware.com/go/powercli

Page 4: PowerCLI Workshop

You need automation to survive the virtual world.

Virtual assets are extremely easy to create.

Some people call it “virtual sprawl”. But virtualization lets us do so much

more – more complexity is inevitable. Tools and skill sets must be upgraded to

match this rise in complexity.

http://vmware.com/go/powercli

Page 5: PowerCLI Workshop

Financial analysis – then.

Page 6: PowerCLI Workshop

Financial analysis – now.

Page 7: PowerCLI Workshop

PowerCLI changes the nature of your work.

In a lot of ways the current state of virtual management is like the accounting department from the 50s. A lot of manual labor.

Complex automation used to be only accessible to dedicated development teams.

But PowerCLI empowers you to do complex automation yourself.

http://vmware.com/go/powercli

Page 8: PowerCLI Workshop

How to get the most out of PowerCLI.

Remember that PowerCLI can automate anything in vSphere.Think about how these possibilities can

change the nature of the things you do every day.

Focus on increasing your productivity.Stop doing things manually.Start focusing on building automation tools

you can use again and again.http://vmware.com/go/powercli

Page 9: PowerCLI Workshop

Overview / Agenda. Getting to know you. Introduction to PowerShell. Introduction to PowerCLI. Managing VMs with PowerCLI. Managing ESX with PowerCLI. Managing Storage with PowerCLI. Managing Network with PowerCLI.

http://vmware.com/go/powercli

Page 10: PowerCLI Workshop

Overview / Agenda (cont). Other PowerCLI topics. Advanced: Intro to the API. Advanced Storage. Advanced Network. Advanced ESX. Other Advanced Topics.

http://vmware.com/go/powercli

Page 11: PowerCLI Workshop

Getting to know you.

How are you using PowerCLI today? Would you say you’re a beginner? Expert? How does PowerCLI integrate into your other

management practices? What things do you wish PowerCLI could do for

you? How do you manage physical + virtual? What is

lacking here? What key things did you hope to learn?

http://vmware.com/go/powercli

Page 12: PowerCLI Workshop

Getting to know you.

Where are you wasting your time?Provisioning?Change management?Troubleshooting?

What business pressures do you face?Supporting a wider variety of applications?Improving availability?Other things?

http://vmware.com/go/powercli

Page 13: PowerCLI Workshop

Intro To PowerShell

http://vmware.com/go/powercli

Page 14: PowerCLI Workshop

Top 5 things to know about PowerShell. The purpose. The cmdlets. The pipeline. The platforms. The products.

http://vmware.com/go/powercli

Page 15: PowerCLI Workshop

PowerShell: The Purpose. IT systems are getting more complex and inter-

connected. Virtualization leads to explosive growth in the

number of assets (network, app, etc) to manage.

Automation is becoming a valuable and needed skill for IT administrators.

PowerShell allows non-programmersto automate.

http://vmware.com/go/powercli

Page 16: PowerCLI Workshop

PowerShell: The cmdlets. PowerShell provides almost 200

commands, called cmdlets, natively. Close to 1,000 more commands are

available through various “snap-ins” (e.g. PowerCLI).

Within PowerShell, type “Get-Command” to see a listing of commands.

http://vmware.com/go/powercli

Page 17: PowerCLI Workshop

PowerShell: The Pipeline. The pipeline is how you compose

commands in PowerShell. Outputs of one command are

automatically made inputs of the next, based on type.

Example:Get-Process notepad | Stop-ProcessGet-VM myvm | Start-VM

http://vmware.com/go/powercli

Page 18: PowerCLI Workshop

PowerShell: The Platforms. PowerShell runs on all versions of

Windows since XP and up. Requires .NET 2.0. PowerShell is installed by default in

Windows 7 and Windows 2008 R2. All future versions of Windows will pre-

install it.

http://vmware.com/go/powercli

Page 19: PowerCLI Workshop

PowerShell: The Products. PowerShell support is required for all

Microsoft server applications.Exchange.Sharepoint.IIS.Many more.And, of course, VMware.

http://vmware.com/go/powercli

Page 20: PowerCLI Workshop

The top 9 most used cmdlets.Name Description

Foreach-Object

Execute code for each object in a collection.

Write-OutputPlace an object on the pipeline (or display on the screen if the pipeline is ending).

Out-File Write data to a file.

Where-Object Filter objects based on the given criteria.

Sort-Object Sort objects based on a specified property.

Get-Content Read data from a file.

Get-Childitem Get the child objects of a given object.

Select-ObjectSelect the specified properties from objects on the pipeline.

Read-Host Read user input.

Page 21: PowerCLI Workshop

The top 9 most used operators.Name Description

-eq Test to see if two objects are equal.

-gt True if object 1 is greater than object 2.

-and True if two Boolean conditions are both true.

-match Perform string matching.

-ne True if two objects are not equal.

-contains True if a list of objects contains a specified object.

-not Negate a Boolean condition.

-lt True if object 1 is less than object 2.

-or True if at least on Boolean condition is true.

Page 22: PowerCLI Workshop

How well do you know PowerShell? Would you say you’re more novice or

expert? Are you using PowerShell to manage

other things such as exchange? Do you view PowerShell as a strategic

direction for your IT OPS? Are the people picking up PowerShell

more “Windows people” or “UNIX people”? http://vmware.com/go/powercli

Page 23: PowerCLI Workshop

Demo

Most Used PowerShell Cmdlets and Operators.

http://vmware.com/go/powercli

Page 24: PowerCLI Workshop

3 Takeaways: Most used cmdlets.

PowerShell provides hundreds of commands that interoperate with VMware commands.

Microsoft continues to invest and expand PowerShell’s reach.

PowerShell + PowerCLI makes it possible to manage everything from virtual infrastructure to guest.

http://vmware.com/go/powercli

Page 25: PowerCLI Workshop

One bonus cmdlet you will need to automate!

Import-CSV. Imports a spreadsheet. Great for doing anything at large scale. Learn this pattern and technique you

won’t regret it!

http://vmware.com/go/powercli

Page 26: PowerCLI Workshop

Demo

Using Import-CSV.

Key cmdlets: Import-CSV Export-CSV Get-Content

http://vmware.com/go/powercli

Page 27: PowerCLI Workshop

3 Takeaways: Import-CSV.

Get familiar with Import-CSV! Two types of automation:

Make the same change to every object in a large set.

Make a different change to each object in a large set.

Import-CSV is an ideal choice for solving the second problem.

http://vmware.com/go/powercli

Page 28: PowerCLI Workshop

5 PowerShell tools you should use.

VESI (Virtualization EcoShell). PowerGUI. Virtu-Al.Net vSphere PowerPack. PowerShell WMI Explorer. PowerShell Plus.

http://vmware.com/go/powercli

Page 29: PowerCLI Workshop

Intro To PowerCLI

http://vmware.com/go/powercli

Page 30: PowerCLI Workshop

Top 5 things to know about PowerCLI. The purpose. The cmdlets. Cmdlet Tetris. The products. The future.

http://vmware.com/go/powercli

Page 31: PowerCLI Workshop

PowerCLI: The Purpose. You need automation.

Because it’s so easy to create virtual assets.

Because you need to keep up with the other guy.

PowerCLI is automation for everyone.Reduce the distance between person who

understands the problem and person who solves it.

PowerCLI is comprehensive. EverythingvCenter can do.

http://vmware.com/go/powercli

Page 32: PowerCLI Workshop

PowerCLI: The Cmdlets. 229 cmdlets in version 4.0 U1. Built on the vSphere Web Services API. Two ways to automate:

Simplified cmdlet approach.Advanced approach using Get-View (API).

More coming every 6 months or so.PowerCLI release philosophy is to release twice a

year and be very responsive to user feedback. Long-term goal to make Get-View

unnecessary.http://vmware.com/go/powercli

Page 33: PowerCLI Workshop

PowerCLI: Cmdlet Tetris. PowerShell commands follow the

pattern Verb-Noun or Verb-Object. For a given Object you will commonly

see these four commands:New-Object, Get-Object, Set-Object,

Remove-Object Look for this pattern to manage the full

lifecycle of a virtual object.http://vmware.com/go/powercli

Page 34: PowerCLI Workshop

PowerCLI: The Products. vCenter:

2.5, 4.0 ESX / ESXi

3.0, 3.5, 4.0 VMware Update Manager (preview)

http://vmware.com/go/powercli

Page 35: PowerCLI Workshop

PowerCLI: The Future. Continue to simplify automation until it

is truly accessible to everyone. Broaden the product portfolio to other

solutions such as SRM, vCloud, etc. Provide a more structured experience

(i.e. not “just a bunch of scripts on some network share”)

http://vmware.com/go/powercli

Page 36: PowerCLI Workshop

Making sense of it all.Cmdlet

Count by area

(4.0U1)

Provisioning

Change / Update

Report / Inventory

Report / Performance

ESX 10 26 17 3

Storage 2 9 6 3

Network 2 6 5 3

VM 12 30 15 3

Guest 3 12 4 3

Tools 2 1 0 3

V. Infrastructure

7 21 9 3

Availability 2 6 3 3

Total 40 111 59 24

Page 37: PowerCLI Workshop

Where do you feel the most pain? Configuring and maintaining ESX hosts? VMs? Reporting? Performance analysis? Troubleshooting?

http://vmware.com/go/powercli

Page 38: PowerCLI Workshop

Use Cases and Demos

http://vmware.com/go/powercli

Page 39: PowerCLI Workshop

PowerCLI Support Matrix (4.0 U1) (Latest)

Windows Vista (32 and 64 bit) Windows 2003 (32 and 64 bit) Windows XP

http://vmware.com/go/powercli

TIPS

Page 40: PowerCLI Workshop

PowerCLI Support Matrix (4.1) (Future!)

Windows 7 (32 and 64 bit) Windows 2008 (32 and 64 bit) Windows Vista (32 and 64 bit) Windows 2003 (32 and 64 bit) Windows XP

http://vmware.com/go/powercli

TIPS

Page 41: PowerCLI Workshop

3 ways to connect.

Use your username and password.Warning: don’t do this except interactively.

Use SSPI / Active Directory if you have it.

Use Import-PSCredential if you don’t.See http://poshcode.org/501

http://vmware.com/go/powercli

TIPS

Page 42: PowerCLI Workshop

Demo

A 5-minute introduction to PowerCLI.

Key cmdlets: Connect-VIServer Get-VMHost Get-VM

http://vmware.com/go/powercli

TIPS

Page 43: PowerCLI Workshop

3 Takeaways: 5 minute intro.

PowerCLI provides more than 200 commands and it’s growing all the time.

PowerCLI manages everything that vCenter manages and more.

PowerCLI makes automation easy enough that anyone can do it.

http://vmware.com/go/powercli

TIPS

Page 44: PowerCLI Workshop

Get-TheMost out of “Help”

Help is PowerShell’s built-in help system.

Everything you need to know is documented in the cmdlet itself.

Supports wildcards “Help *VM*” All PowerCLI cmdlets have examples.

“Help <cmdlet> -examples”“Help <cmdlet> -full”

http://vmware.com/go/powercli

TIPS

Page 45: PowerCLI Workshop

Get-TheMost out of “Get” cmdlets.

Learn how to string Get-Cmdlets together.Example: Get-Cluster X | Get-VMHost | Get-VM to

select all VMs in a cluster. PowerCLI cmdlets are designed to navigate

similar to the vSphere Client hierarchy.But PowerCLI can do things vSphere Client can’t.

You can learn this from them help but easierto just try it out.

Demo.http://vmware.com/go/powercli

TIPS

Page 46: PowerCLI Workshop

PowerCLI supports multiple connections.

Starting in PowerCLI 4.0 U1 you can connect to multiple vCenter or ESX servers at the same time.

Now you can automate across multiple vCenters or across multiple ESX even if vCenter is unavailable.

Demo.

http://vmware.com/go/powercli

TIPS

Page 47: PowerCLI Workshop

The top 9 VM-related cmdlets.Name Description

New-VM Create a new VM either from template or blank.

Get-VM Lists all VMs in a container.

Set-VM Changes VM settings such as memory size, etc.

Remove-VM Unregister or delete a VM.

Start-VM Start a VM.

Reset-VM Reboot a VM.

Get-VMGuest Gets a guest information including IP address, etc.

New-Snapshot Create a snapshot of a VM.

Get-Snapshot Enumerate VM snapshots.

VMS

Page 48: PowerCLI Workshop

Managing VMs with PowerCLI.

Provisioning. Change / Update.

Change its resource allocation (e.g. memory).

Change its networking.Add/remove storage.

VMware Tools.

http://vmware.com/go/powercli

VMS

Page 49: PowerCLI Workshop

What challenges do you face around VMs?

Do you tend to provision VMs in bunches or one-at-a-time?

What software do you use to provision? How do you provision lots of VMs? How often? Do you use templates or PXE-based builds? How are you increasing your VM

management ratios? How do you detect wasted VM resources?

http://vmware.com/go/powercli

VMS

Page 50: PowerCLI Workshop

3 ways to provision your VMs.

Creating blank VMs and PXE booting them.

Clone a template. Clone a VM while running.

http://vmware.com/go/powercli

VMS

Page 51: PowerCLI Workshop

Demo

Provisioning at large scales.

Key cmdlets: New-VM Get-Template Get-OSCustomizationSpec

http://vmware.com/go/powercli

VMS

Page 52: PowerCLI Workshop

3 Takeaways: Large-scale provisioning.

Whether you use templates or not, PowerCLI makes it easy to provision.

Even if you use static IP addresses PowerCLI can automate it.

Large-scale provisioning and Import-CSV were virtually made for each other.

http://vmware.com/go/powercli

VMS

Page 53: PowerCLI Workshop

Demo

Large-scale VM Updates.

Key cmdlets: Get-VM Set-VM

http://vmware.com/go/powercli

VMS

Page 54: PowerCLI Workshop

3 Takeaways: VM Updates.

Large-scale updates are easy with Set-VM.

Master Get-* and Where cmdlets to target exactly the VMs you want.

If you’re worried about the impact, use –whatif.

http://vmware.com/go/powercli

VMS

Page 55: PowerCLI Workshop

Demo

Dealing with snapshots.

Key cmdlets: Get-Snapshot Remove-Snapshot Where-Object

http://vmware.com/go/powercli

VMS

Page 56: PowerCLI Workshop

3 Takeaways: Snapshots.

Snapshots are the “silent datastore killer”.

Track their age and size with PowerCLI. Deleting lots of snapshots is a snap

(sorry).

http://vmware.com/go/powercli

VMS

Page 57: PowerCLI Workshop

The top 8 ESX-related cmdlets.Name Description

Add-VMHost Add an ESX host to vCenter.

Get-VMHost Enumerate ESX hosts in a container (e.g. cluster)

Restart-VMHost Restart an ESX host.

Get-VMHostHBA Get ESX Host Bus Adapters.

Get-VMHostFirmware Get a backup of an ESXi host.

Get-VMHostNetworkAdapter

Get ESX host network adapters including info like ESX IP address.

Set-VMHostNetworkAdapter

Change ESX host network adapters including IP, MAC address, etc.

Apply-VMHostProfile Configure ESX using Host Profiles.

ESX

Page 58: PowerCLI Workshop

Managing ESX with PowerCLI.

Provisioning (Host profiles or scripted) Change / Update.

Storage.Network.Security, etc.

Managing power and connection state.

http://vmware.com/go/powercli

ESX

Page 59: PowerCLI Workshop

What challenges do you face deploying ESX?

What software do you use to deploy? How do you track inventory and

monitor ESX? How do you manage the ESX / vCenter

relationship? How do you manage storage and

network to your ESX systems? How are you planning to deal with ESXi?

http://vmware.com/go/powercli

ESX

Page 60: PowerCLI Workshop

2 ways to provision your ESX hosts.

Host Profiles.Provision one server just the way you like it.“Stamp out” the configuration to other

servers. Home-grown scripts (covered later).

Run a custom script to do complete configuration of a server.

http://vmware.com/go/powercli

ESX

Page 61: PowerCLI Workshop

Demo

Dealing with Host Profiles.

Key cmdlets: Get-VMHostProfile Apply-VMHostProfile Test-VMHostProfileCompliance

http://vmware.com/go/powercli

ESX

Page 62: PowerCLI Workshop

3 Takeaways: Host Profiles.

Host Profiles simplify the process of creating identically configured ESX hosts.

The purpose of profiles is avoiding cost and complexity “I don’t have to worry about a million things.”

Host Profiles are a strategic direction for VMware and will continue to improve.

http://vmware.com/go/powercli

ESX

Page 63: PowerCLI Workshop

Why we cluster.

Clustering is the heart of VMware’s real value.High availability.Automated resource management and

balancing. PowerCLI gives complete and granular

control over cluster configuration.

http://vmware.com/go/powercli

ESX

Page 64: PowerCLI Workshop

Demo

Clustering your hosts for max availability.

Key cmdlets: New-Cluster Set-Cluster Move-VMHost

http://vmware.com/go/powercli

ESX

Page 65: PowerCLI Workshop

2 Takeaways: Clustering.

In the past all interesting VMware functionality happened at the host level. Recently this has been moving to cluster (eventually to datacenter).

PowerCLI gives you the tools you need to configure, monitor and audit your clusters.

http://vmware.com/go/powercli

ESX

Page 66: PowerCLI Workshop

You can also automate DRS rules.

Key cmdlets:New-DrsRuleGet-DrsRuleSet-DrsRuleRemove-DrsRule

http://vmware.com/go/powercli

ESX

Page 67: PowerCLI Workshop

The top 9 storage-related cmdlets.Name Description

New-Datastore Create a new NFS or VMFS datastore.

Get-Datastore Enumerate existing datastores.

Remove-Datastore

Remove a datastore.

Get-VMHostStorage

List ESX storage properties or rescan ESX storage.

Get-ScsiLun Enumerate SCSI LUNs visible to ESX.

Get-ScsiLunPath Enumerate the LUN paths for a SCSI LUN.

Get-VMHostHBA Enumerate an ESX host’s Host Bus Adapters.

Set-VMHostHBAConfigure an HBA including iSCSI authentication parameters.

vmstore: A filesystem-based datastore browser.

STORAGE

Page 68: PowerCLI Workshop

Managing Storage with PowerCLI.

Adding existing datastores or formatting new.

Rescanning storage. Capacity and utilization reports. Identifying datastores that are not

visible to the entire cluster.

http://vmware.com/go/powercli

STORAGE

Page 69: PowerCLI Workshop

What challenges do you face around storage?

Do you have a dedicated storage team? How well do storage and virtualization interact?

Do you have separate storage management tools?

How do you identify and resolve storage bottlenecks?

When users complain about slow applications, what do you do?

http://vmware.com/go/powercli

STORAGE

Page 70: PowerCLI Workshop

Storage VMotion is a snap.

Move-VM is a versatile command. If you use –Datastore you will Storage

VMotion.

http://vmware.com/go/powercli

STORAGE

Page 71: PowerCLI Workshop

Demo

VMotion and Storage VMotion with Move-VM.

Key cmdlets: Move-VM Get-VMHost Get-Datastore

http://vmware.com/go/powercli

STORAGE

Page 72: PowerCLI Workshop

3 Takeaways: Storage VMotion.

Performing a Storage VMotion can take a really long time.

Perfect reason to script it. Try to beat this simplicity:

Get-VM –Datastore ds1 | Move-VM –Datastore ds2

http://vmware.com/go/powercli

STORAGE

Page 73: PowerCLI Workshop

Save money with thin provisioning.

Allocate space as it is used rather than all at once.

Huge space savings at the cost of some performance.

You can provision new VMs thin or convert existing with PowerCLI.

http://vmware.com/go/powercli

STORAGE

Page 74: PowerCLI Workshop

Demo

Thin Provisioning.

Key cmdlets: New-VM New-Harddisk Set-Harddisk

http://vmware.com/go/powercli

STORAGE

Page 75: PowerCLI Workshop

3 Takeaways: Thin Provisioning.

Storage is expensive! Why pay for the parts you’re not using?

With simple PowerCLI scripts you can change existing VMs to use thin provisioning.

Or just build an easy report to see how much you’re using or how much you could save.

http://vmware.com/go/powercli

STORAGE

Page 76: PowerCLI Workshop

Demo

Adding NFS Datastores to ESX.

Key cmdlets: New-Datastore

http://vmware.com/go/powercli

STORAGE

Page 77: PowerCLI Workshop

2 Takeaways: NFS Datastores.

Adding and auditing NFS datastores is simple with PowerCLI.

Warning: NFS performance statistics are not available (coming in a future version of vSphere).

http://vmware.com/go/powercli

STORAGE

Page 78: PowerCLI Workshop

The top 9 network-related cmdlets.Name Description

New-VirtualSwitch Create a virtual switch (classic only!)

Get-VirtualSwitch Enumerate virtual switches.

New-VirtualPortGroup Create a portgroup with a virtual switch.

Set-VirtualPortGroup Modify a portgroup.

New-NetworkAdapter Create a new network adapter for a VM.

Get-NetworkAdapter Enumerate a VM’s network adapter.

Set-NetworkAdapterModify a VM’s network adapter properties (e.g. MAC)

Remove-NetworkAdapter

Remove a VM’s network adapter.

Set-VMHostNetworkAdapter

Modify an ESX host’s network adapter.

NETWORK

Page 79: PowerCLI Workshop

Managing Networking with PowerCLI.

Adding or configuring VMKernel. Moving VMs between virtual switches. Configuring virtual switch policies.

http://vmware.com/go/powercli

NETWORK

Page 80: PowerCLI Workshop

What challenges do you face around network?

How do you manage the interaction between virtual and physical switch? Example: VLAN, CDP.

How do you ensure consistent network configuration across ESX hosts?

Do you use trunking for max performance? Have you encountered problems doing this?

http://vmware.com/go/powercli

NETWORK

Page 81: PowerCLI Workshop

Demo

Moving VMs between networks.

Key cmdlets: Get-NetworkAdapter Set-NetworkAdapter

http://vmware.com/go/powercli

NETWORK

Page 82: PowerCLI Workshop

2 Takeaways: Changing VM Networks.

Moving VMs from one network to another is quick and easy.

If a virtual switch is re-created, on purpose or by accident, your VMs will all be disconnected. You can solve that with one line of PowerCLI.

http://vmware.com/go/powercli

NETWORK

Page 83: PowerCLI Workshop

Demo

Configuring Consistent Virtual Switches.

Key cmdlets: New-VirtualSwitch Get-VirtualSwitch

http://vmware.com/go/powercli

NETWORK

Page 84: PowerCLI Workshop

3 Takeaways: Virtual Switches.

Creating consistent virtual switches is key for many VMware features such as DRS.

Creating switches manually is insane, especially considering the simplicity of PowerCLI.

You can also set policy items like failover and load balancing (covered later). http://vmware.com/go/powercli

NETWORK

Page 85: PowerCLI Workshop

The top 5 reporting cmdlets.Name Description

Get-* Enumerate all sorts of virtual inventory.

Get-Stat Get performance statistic for any inventory item.

Get-VIEvent List all events.

Export-CSV Write objects to CSV-formatted output.

ConvertTo-Html

Convert objects to HTML.

REPORTS

Page 86: PowerCLI Workshop

Reporting with PowerCLI.

Three major categories of PowerCLI reports.Inventory-based reporting.Statistic-based reporting (i.e. performance)Event-based reporting.

http://vmware.com/go/powercli

REPORTS

Page 87: PowerCLI Workshop

Reporting with PowerCLI.

What reporting tools do you use today? Do you think they are good?

Do you use reports more for planning or more for reacting to problems?

Where do you feel you are “in the dark”?

http://vmware.com/go/powercli

REPORTS

Page 88: PowerCLI Workshop

Inventory-based reporting.

Relies on Get-* cmdlets as a starting point.

Generally combined with Export-CSV or ConvertTo-Html.

http://vmware.com/go/powercli

REPORTS

Page 89: PowerCLI Workshop

Report on your guest disk capacity.

Basic report. Sort by least % free space. Show all guests with <10% free space.

http://vmware.com/go/powercli

REPORTS

Page 90: PowerCLI Workshop

Demo

Reporting on Guest Disk Capacity.

Key cmdlets: Get-VM Get-Harddisk

http://vmware.com/go/powercli

REPORTS

Page 91: PowerCLI Workshop

3 Takeaways: Guest Disks.

Relies on VMware Tools! Avoid a disaster by identifying disks

that are about to overflow. Also makes it easy to understand how

much thin provisioning would save you.

http://vmware.com/go/powercli

REPORTS

Page 92: PowerCLI Workshop

Reporting with custom attributes.

Custom attributes are extremely useful for tracking things unique to your deployment.Example: VM owner, app owner, etc.

Get-CustomAttribute.

http://vmware.com/go/powercli

REPORTS

Page 93: PowerCLI Workshop

Demo

Reporting with Custom Attributes.

Key cmdlets: Get-CustomAttribute Get-Inventory

http://vmware.com/go/powercli

REPORTS

Page 94: PowerCLI Workshop

3 Takeaways: Custom Attributes.

If you’re not using custom attributes – start!

Audit your custom attributes to determine compliance (all the data is there and accurate)

You should set attributes as part of your provisioning process.

http://vmware.com/go/powercli

REPORTS

Page 95: PowerCLI Workshop

Demo

Security reporting using roles and permissions.

Key cmdlets: Get-VIUser Get-VIRole

http://vmware.com/go/powercli

REPORTS

Page 96: PowerCLI Workshop

3 Takeaways: Roles and Permissions.

PowerCLI gives you all the tools you need to audit roles and permissions.

With Quest’s ActiveRoles you can load Active Directory information for more useful reports.

With PowerCLI you can easily duplicate roles and permissions between vCenter instances.

http://vmware.com/go/powercli

REPORTS

Page 97: PowerCLI Workshop

Statistic-based reporting.

Relies on Get-Stat as a starting point. Commonly you will rank the results. This can feed into other script logic or

be exported like an inventory report would be exported.

http://vmware.com/go/powercli

REPORTS

Page 98: PowerCLI Workshop

Get-TheMost out of Get-Stat. Get-StatType identifies available

statistics. Understanding instances is critical. Note: vCenter and ESX may report

different types of statistics.

http://vmware.com/go/powercli

REPORTS

Page 99: PowerCLI Workshop

Demo

Introduction to statistic-based reporting.

Key cmdlets: Get-Stat

http://vmware.com/go/powercli

REPORTS

Page 100: PowerCLI Workshop

3 Takeaways: Reporting with Statistics.

Querying statistics help you identify and solve performance problems.

Stats on vCenter are determined by stat level. The higher the level the more stats you have.

If you query ESX directly all stats are available but for short periods (5 mins on 3.5, 1hr on 4.0)

http://vmware.com/go/powercli

REPORTS

Page 101: PowerCLI Workshop

Top 8 Most Interesting Statistics.Name Description

cpu.usage.average CPU usage as a percentage of total.

cpu.usagemhz.average CPU usage in MHz of CPU used.

cpu.ready.summationAmount of time a VM is ready to run but can’t due to not enough cores available.

mem.usage.average Average memory usage.

disk.read.average Average amount of data read from the disk.

disk.write.average Average amount of data written to disk.

disk.totalreadlatancy.average

Average LUN read latency in milliseconds.

disk.totalwritelatency.average

Average LUN write latency in milliseconds.

REPORTS

Page 102: PowerCLI Workshop

Demo

Most and least busy VMs and Hosts.

Key cmdlets: Get-Stat

http://vmware.com/go/powercli

REPORTS

Page 103: PowerCLI Workshop

2 Takeaways: Host and VM Usage.

Identifying overused resources it the first step to effective rebalancing.

With PowerCLI you get a complete picture all at once no matter how many hosts or VMs you have.

http://vmware.com/go/powercli

REPORTS

Page 104: PowerCLI Workshop

Event-based reporting.

Relies on Get-VIEvent as a starting point.

Most vSphere actions create events in order to generate an audit trail.

This audit trail can be followed and inspected for a large number of uses.

http://vmware.com/go/powercli

REPORTS

Page 105: PowerCLI Workshop

Demo

Introduction to event-based reporting.

Key cmdlets: Get-VIEvent

http://vmware.com/go/powercli

REPORTS

Page 106: PowerCLI Workshop

3 Takeaways: Event-based reporting.

Events tell you who did what when. ESX retains a fixed number of events,

vCenter retains all events since a given date.

Before you report events be sure to understand your vCenter’s event retention policy.

http://vmware.com/go/powercli

REPORTS

Page 107: PowerCLI Workshop

Demo

When was that VM powered on?

Key cmdlets: Get-VIEvent

http://vmware.com/go/powercli

REPORTS

Page 108: PowerCLI Workshop

3 Takeaways: Determining VM Poweron Date.

Just one of many reports you can do with events.

Others:If an outage occurs you can find which

modifications may have contributed to the outage using –Start and –Finish.

Track who logged in and when.

http://vmware.com/go/powercli

REPORTS

Page 109: PowerCLI Workshop

You can get your VM’s log file too.

Get to know vmstore: Use Copy-DatastoreItem to bridge the

gap between local and remote.

http://vmware.com/go/powercli

REPORTS

Page 110: PowerCLI Workshop

This report will make your manager love you (in a completely legal way).

Alan Renouf’s Daily Report. Reports:

Numbers of objects in inventory (VMs, hosts, etc)Datastores running out of space.Snapshots over X days old.Disconnected hosts.Lots more!

All emailed to you every morning! http://www.virtu-al.net/2009/11/04/vcheck-daily-

report-v3/

http://vmware.com/go/powercli

REPORTS

Page 111: PowerCLI Workshop

Stuff Alan’s Daily Report Will Tell You. Number of Hosts Number of VMs Number of Datastores Number of DRS Migrations for the last days Snapshots over x Days old Datastores with less than x% free space VMs created over the last x days VMs with No Tools VMs with CD-Roms connected VMs with CPU ready over x% Hosts in Maintenance Mode VC Error Events over the last x days VC Windows Event Log Errors for the last x days with VMware in the details VM active alerts Cluster Active Alerts vSphere check: Outdated VM Hardware (Less than V7) VMs in Inconsistent folders (the name of the folder is not the same as the name)

http://vmware.com/go/powercli

REPORTS

Page 112: PowerCLI Workshop

Sample Daily Report Output.REPORTS

Page 113: PowerCLI Workshop

The top 9 other cmdlets.Name Description

Move-VM VMotion or Storage VMotion a VM.

Set-ClusterMost advanced vSphere features operate on a cluster level. This cmdlet gives you control over clusters.

New-CustomAttribute

Custom attributes let you add your own notes and properties to vSphere items.

Set-AnnotationAnnotations define the value of an attribute for an object.

Get-VIRole This cmdlet makes it easy to audit roles.

Get-VIPermission This cmdlet makes it easy to audit permissions.

Import-VApp Importing a Virtual Appliance is simple with PowerCLI.

Invoke-VMScriptWith this command you can run scripts within your guests.

Get-View This cmdlet is the gateway to the vSphere API.

TIPS

Page 114: PowerCLI Workshop

Top 5 PowerCLI FAQs (With answers!)

How to upgrade VMware Tools with no reboot?

How to move only one disk during Storage VMotion?

How to change the ESX host’s root password?

How do I take lots of actions simultaneously?

How to get the VM’s UUID? http://vmware.com/go/powercli

TIPS

Page 115: PowerCLI Workshop

Top 5 PowerCLI FAQs (With answers!)

How to upgrade VMware Tools with no reboot?New in PowerCLI 4.0 U1, Update-Tools –

NoReboot How to move only one disk during Storage

VMotion?Use Set-HardDisk –Datastore.Bug: Requires the VM to be powered off. This is

fixed in 4.1.

http://vmware.com/go/powercli

TIPS

Page 116: PowerCLI Workshop

Top 5 PowerCLI FAQs (With answers!)

How to change the ESX host’s root password?Connect directly to the ESX host.Use Get-VMHostAccount / Set-VMHostAccount.

How do I take lots of actions simultaneously?Most PowerCLI commands support the –Runasync

flag, which causes jobs to run in the background.Use this along with Wait-Task.Demo.

http://vmware.com/go/powercli

TIPS

Page 117: PowerCLI Workshop

Top 5 PowerCLI FAQs (With answers!)

How to get the VM’s UUID?Inside the view property config.uuidGet-VM | Select Name, { ($_ | Get-

View).config.uuid }Or using object extensions (upcoming

feature).Demo.

http://vmware.com/go/powercli

TIPS

Page 118: PowerCLI Workshop

Secure your scripts with these tips.

You can configure PowerShell to not run unsigned scripts.

Set-ExecutionPolicy AllSigned PowerShell Plus has built-in script

signing.

http://vmware.com/go/powercli

TIPS

Page 119: PowerCLI Workshop

3 mistakes you need to avoid! Careful when using New-Snapshot!

Use –Memory if you want to revert to the snapshot without powering the VM off.

Careful when deleting that VM!If you don’t use –DeleteFromDisk it will

simply be unregistered. Don’t use Write-Host!

Except as debugging, instead useWrite-Output.

http://vmware.com/go/powercli

TIPS

Page 120: PowerCLI Workshop

4 tips to make your scripts more readable

Use object names rather than separate cmdlet calls.

Use line continuation (backticks) when necessary.

Factor code into functions. Use PowerGUI, VESI, or PowerShell Plus

for syntax highlighting.

http://vmware.com/go/powercli

TIPS

Page 121: PowerCLI Workshop

Demo

Maximizing readability and maintainability.

http://vmware.com/go/powercli

TIPS

Page 122: PowerCLI Workshop

3 Takeaways: Readability.

Readable code is maintainable code. Take maximum advantage of Object-By-

Name. The pipeline separates PowerShell from

other languages. Use it a lot and your readability will greatly improve.

http://vmware.com/go/powercli

TIPS

Page 123: PowerCLI Workshop

Demo

Speeding up your scripts.

http://vmware.com/go/powercli

TIPS

Page 124: PowerCLI Workshop

3 Takeaways: Speeding up your scripts.

PowerShell does not optimize scripts. Factor variables out manually.

Be aware of the performance penalties OBN introduces. If you have the object handy, don’t use its name.

If your scripts are slow, consider caching more objects client-side.

http://vmware.com/go/powercli

TIPS

Page 125: PowerCLI Workshop

1 feature you absolutely need to know.

Object Extensions. Is your favorite object missing a

property? Add it yourself! This will fundamentally change the way

you script and report. “PowerCLI 2.0” Demo.

http://vmware.com/go/powercli

TIPS

Page 126: PowerCLI Workshop

Demo (Future Features)

Simplifying Reporting With Object Extensions.

Key cmdlets: New-VIObjectExtensionProperty (Name subject to change)

http://vmware.com/go/powercli

TIPS

Page 127: PowerCLI Workshop

3 Takeaways: Object Extensions.

Object Extensions will radically simplify your scripts and reports.

If you ever wished an object had a certain property or field, find it in the API and you will soon be able to add it yourself.

Coming soon in PowerCLI 4.1.

http://vmware.com/go/powercli

TIPS

Page 128: PowerCLI Workshop

Learn to write a PowerShell Advanced Function

PowerShell Advanced Functions function almost exactly like PowerShell cmdlets.

You can write scripts that:Sit in the PowerShell pipeline.Interoperate with all PowerCLI cmdlets.

Demo. “help about_functions_advanced”. See “VI Toolkit Extensions” for samples.

http://vmware.com/go/powercli

TIPS

Page 129: PowerCLI Workshop

Learn to write a PowerShell Advanced Function

PowerShell Advanced Functions function almost exactly like PowerShell cmdlets.

You can write scripts that:Sit in the PowerShell pipeline.Interoperate with all PowerCLI cmdlets.

Demo. “help about_functions_advanced”. See “VI Toolkit Extensions” for samples.

http://vmware.com/go/powercli

TIPS

Page 130: PowerCLI Workshop

Anatomy of an advanced function.TIPS

function Advanced-Function { param( [Parameter(Mandatory=$true,...] [VMware.VimAutomation.Client20.VMHostImpl] $VMHost ) Begin { ... } Process { ... } End { ... }}

Initialize at the start of the pipeline (opt)

Process each object in the pipeline.

Called at the end of the pipeline (opt)

Page 131: PowerCLI Workshop

Sample advanced function: ESX Host Routes.

Demo.

http://vmware.com/go/powercli

TIPS

Page 132: PowerCLI Workshop

Resources

http://vmware.com/go/powercli

Page 133: PowerCLI Workshop

3 must-own resources:

Managing VMware Infrastructure with Windows PowerShell.

vSphere 4.0 Quick Start Guide. VMware vSphere Pro Series Training.

http://vmware.com/go/powercli

TIPS

Page 134: PowerCLI Workshop

http://vmware.com/go/powercli

The “PowerCLI Bible”TIPS

Page 135: PowerCLI Workshop

http://vmware.com/go/powercli

Lots of PowerCLI Samples.TIPS

Page 136: PowerCLI Workshop

New training from TrainSignal!TIPS

Page 137: PowerCLI Workshop

6 Amazing Blogs to Follow:Address Why it’s great:

http://www.virtu-al.net/ Alan Renouf has collected tons of great scripts into a PowerPack, including amazing reports.

http://lucd.info/ Luc Dekens is the world’s leading PowerCLI expert.

http://ict-freak.nl/ Arne Fokkema heeft veel grote scripts!

http://professionalvmware.com/

Cody Bunch is an automation master at a large, US based hosting and PAAS provider.

http://get-admin.com/blog/ Glenn Sizemore has a great collection of VMware and NetApp scripts.

http://blogs.vmware.com/vipowershell

The VMware PowerCLI blog.

TIPS

Page 138: PowerCLI Workshop

The most important resource of all:

The PowerCLI Community. http://vmware.com/go/powercli More than 500 scripts. Search a huge and growing

knowledgebase. Ask questions and get answers.

http://vmware.com/go/powercli

TIPS

Page 139: PowerCLI Workshop

By Sheer Coincidence.

PowerShell Master Class [3 dagar] Instructor: Thomas Lee, PowerShell MVP Begins 2010-03-09 http://www.labcenter.se/Lab/2056

http://vmware.com/go/powercli

TIPS

Page 140: PowerCLI Workshop

Advanced Stuff!

http://vmware.com/go/powercli

Page 141: PowerCLI Workshop

The vSphere API Stack.API

Page 142: PowerCLI Workshop

Managed objects and automation objects.

PowerCLI uses two object models.Automation objects: Small objects containing

only the most critical data. Returned by Get-* cmdlets (example Get-VM).

View objects: Full objects with no properties missing. Not optimized for usability.

You can easily transition between the two.Get-View: Automation to view object.Get-VIObjectByVIView: View to automation.

http://vmware.com/go/powercli

API

Page 143: PowerCLI Workshop

Explore the vSphere API with PowerCLI.

Get-View is your gateway to the API. You can pipe most objects to Get-View. Some objects have hard-coded names

and can must be loaded directly.E.g. Get-View ServiceContent

http://vmware.com/go/powercli

API

Page 144: PowerCLI Workshop

You can do anything with Get-View.

When you load a view with Get-View all its properties and methods are available to you.

You can see all this with PowerShell’s Get-Member cmdlet.

http://vmware.com/go/powercli

API

Page 145: PowerCLI Workshop

Demo

Use Get-View and Get-Member to explore the API.

Key cmdlets: Get-View Get-Member

http://vmware.com/go/powercli

API

Page 146: PowerCLI Workshop

4 Takeaways: Get-View.

Get-View opens the full power of the API to you.

You can do anything vCenter can do using this API.

But: you have to use the vSphere API, which can be quite challenging.

Refer to the docs:http://www.vmware.com/support/developer/vc-sdk/

visdk400pubs/ReferenceGuide/index.html

http://vmware.com/go/powercli

API

Page 147: PowerCLI Workshop

Surviving the vSphere API Documentation.

Most useful starting points: Search within:All managed objects – OR –All methods.

API has managed objects and data objects.Managed objects define methods, data

objects do not.

http://vmware.com/go/powercli

API

Page 148: PowerCLI Workshop

Surviving the vSphere API Documentation (cont)

When calling managed object methods you will generally need to supply some data objects.

Managed objects are returned by PowerCLI’s Get-View cmdlet.

Data objects are constructed by PowerShell’s New-Object cmdlet.New-Object

VMware.Vim.VirtualMachineConfigSpec

API

Page 149: PowerCLI Workshop

Using “Project Onyx”.

Onyx is a code generator. Sits between vSphere Client and

vCenter. Any UI click is automatically turned to

code.

http://vmware.com/go/powercli

API

Page 150: PowerCLI Workshop

“Project Onyx” Architecture.API

ESX or vCenter

Page 151: PowerCLI Workshop

Demo

Using Onyx.

http://vmware.com/go/powercli

API

Page 152: PowerCLI Workshop

3 Takeaways: Onyx.

Onyx makes it simple to understand what calls vSphere Client makes and when.

From this you can understand the best practices and tested code paths VMware uses.

Warning: You will need to re-factor code generated by Onyx.

http://vmware.com/go/powercli

API

Page 153: PowerCLI Workshop

Advanced VM management topics. PowerCLI can run commands inside

your guests. You can granularly control the

placement of memory and snapshot files.

Using View? PowerCLI gives you granular control over VM video memory.

http://vmware.com/go/powercli

VMS

Page 154: PowerCLI Workshop

2 ways to manage your guests. With PowerShell / PowerCLI you can

manage inside your guest too. Option 1: WMI over the network. Option 2: Invoke-VMScript and related

cmdlets via VMware Tools.

http://vmware.com/go/powercli

VMS

Page 155: PowerCLI Workshop

Demo

Guest management.

Key cmdlets: Invoke-VMScript Copy-GuestFile

http://vmware.com/go/powercli

VMS

Page 156: PowerCLI Workshop

3 Takeaways: Guest Management.

Run programs in your guest or copy files there.You could combine these to install software

agents, etc. Supports Windows or Linux. Works even if your VM’s network is

down or disconnected.

http://vmware.com/go/powercli

VMS

Page 157: PowerCLI Workshop

More advanced guest management: Customizing the scripts.

Certain guest cmdlets can be completely re-wired by substituting their scripts.

Script sources located at $env:PROGRAMFILES\VMware\Infrastructure\vSphere PowerCLI\Scripts

http://vmware.com/go/powercli

VMS

Page 158: PowerCLI Workshop

Demo

Changing swap and memory location.

Key cmdlets: Get-View

http://vmware.com/go/powercli

VMS

Page 159: PowerCLI Workshop

4 Takeaways: Changing swap location.

Take advantage of cheaper storage for less critical data.

Controllable on a per-cluster, per-host, or per-vm basis.

Changes location for both snapshot and virtual memory.

Warning: Decreases average reliability.

http://vmware.com/go/powercli

VMS

Page 160: PowerCLI Workshop

Advanced storage management topics.

All about iSCSI. Storage path reporting and

management. Telling the difference between shared

and unshared storage. Reporting on LUN performance. Configuring queue depth.

http://vmware.com/go/powercli

STORAGE

Page 161: PowerCLI Workshop

Adding iSCSI datastores.

Adding iSCSI to ESX is a good deal more complex.

But it offers more options and security features.

PowerCLI can add the storage with or without authentication.

http://vmware.com/go/powercli

STORAGE

Page 162: PowerCLI Workshop

Demo

Adding iSCSI to your hosts.

Key cmdlets: Get-VMHostStorage Get-ScsiLun New-Datastore

http://vmware.com/go/powercli

STORAGE

Page 163: PowerCLI Workshop

3 Takeaways: Using iSCSI.

iSCSI comes in two flavors, software and hardware.

To use software iSCSI you must enable the virtual iSCSI adapter.

iSCSI has richer security capabilities than NFS. This leads to higher complexity.

PowerCLI has very rich support for iSCSI. http://vmware.com/go/powercli

STORAGE

Page 164: PowerCLI Workshop

Two types of storage for your VMs.

VMDK-based virtual hard disks. Raw devices (RDM). Warning: Think hard before using RDM!

Won’t overcome size limitations!Won’t necessarily give you better

performance!

http://vmware.com/go/powercli

STORAGE

Page 165: PowerCLI Workshop

Demo

Finding and mounting raw devices.

Key cmdlets: Get-ScsiLun New-Harddisk

http://vmware.com/go/powercli

STORAGE

Page 166: PowerCLI Workshop

3 Takeaways: Raw Devices.

Raw devices are necessary in some applications such as MSCS.

PowerCLI makes it easy to mount, unmount and report on raw devices.

Warning: If you don’t need raw devices you probably shouldn’t use them.

http://vmware.com/go/powercli

STORAGE

Page 167: PowerCLI Workshop

Demo

Find VMs on unshared storage.

Key cmdlets: Get-View Get-Datastore Get-VM

http://vmware.com/go/powercli

STORAGE

Page 168: PowerCLI Workshop

3 Takeaways: Unshared VMs.

VMs on unshared storage can’t participate in many advanced vSphere features such as DRS.

If you’ve got hundreds or thousands of VMs you have to automate finding unshared VMs.

PowerCLI also makes it easy to solve the problem: with Move-VM.

http://vmware.com/go/powercli

STORAGE

Page 169: PowerCLI Workshop

Demo

Determining LUN Performance.

Key cmdlets: Get-Stat Warning: Doesn’t work with NFS

storage.

http://vmware.com/go/powercli

STORAGE

Page 170: PowerCLI Workshop

3 Takeaways: LUN Performance.

LUN latency is a key statistic to watch. If it gets too high, workloads will be affected.

There are no real standards but a pretty good suggestion is:Virtual desktops: Users will start complaining at about

20ms latency.Non-interactive, workloads: will be impacted around

40ms latency. Once you identify the problem, solve it

with PowerCLI’s Move-VM.

http://vmware.com/go/powercli

STORAGE

Page 171: PowerCLI Workshop

Configuring adapter queue depth.

By default your adapter’s queue depth is 32. This can be adjusted. Warning: adjustments require host reboots. Warning: May increasing queue depth may

worsen performance depending on your storage network and storage.

http://frankdenneman.wordpress.com/2009/03/04/increasing-the-queue-depth/

http://vmware.com/go/powercli

STORAGE

Page 172: PowerCLI Workshop

Demo

Configuring adapter queue depth.

Key cmdlets: Set-VMHostModule

http://vmware.com/go/powercli

STORAGE

Page 173: PowerCLI Workshop

3 Takeaways: Queue Depth.

Increasing queue depth can improve your storage performance.

It can also harm it, especially on LUNs shared by lots of hosts.

Be sure to read and understand all factors in play before making any changes.

http://vmware.com/go/powercli

STORAGE

Page 174: PowerCLI Workshop

Advanced network management.

Advanced switch and portgroup policies.

Creating and updating your service consoles.

http://vmware.com/go/powercli

NETWORK

Page 175: PowerCLI Workshop

Demo

Advanced Network Management.

Key cmdlets XXX need demo copied to desktop: Get-NicTeamingPolicy Set-NicTeamingPolicy

http://vmware.com/go/powercli

NETWORK

Page 176: PowerCLI Workshop

3 Takeaways: Advanced Network Management.

Policies can be set on a per-switch or per-portgroup basis.

Switch policies are inherited by portgroups unless they are explicitly overridden.

The right policy is critical to effective operation and high availability of your ESX hosts. PowerCLI helps you be consistent. http://vmware.com/go/powercli

NETWORK

Page 177: PowerCLI Workshop

Advanced ESX management.

ESX build scripts. Setting advanced configuration

parameters. Licensing.

http://vmware.com/go/powercli

ESX

Page 178: PowerCLI Workshop

ESX build scripts you can use.

Lance Berc’s “How To Configure Freshly Booted ESX with PowerShell”http://communities.vmware.com/thread/

161304 Stephen’s Campbell’s “Not Another ESX

Provisioning Script”http://communities.vmware.com/docs/DOC-

8170

http://vmware.com/go/powercli

ESX

Page 179: PowerCLI Workshop

Demo

Advanced Host Options.

Key cmdlets: Set-VMHostAdvancedConfiguration

http://vmware.com/go/powercli

ESX

Page 180: PowerCLI Workshop

3 Takeaways: Advanced Host Options.

There are hundreds of advanced host options.

Some vendors (example NetApp) recommend specific settings for some options. PowerCLI ensures you can set and audit these consistently.

Warning: advanced options regularly change between releases.

http://vmware.com/go/powercli

ESX

Page 181: PowerCLI Workshop

Demo

Licensing.

Key cmdlets: Get-View

http://vmware.com/go/powercli

ESX

Page 182: PowerCLI Workshop

3 Takeaways: Licensing.

Applying a license is a necessary step in any ESX build script.

Licensing changed a lot for vSphere. Different calls are needed depending on

if you are connected to ESX or vCenter.

http://vmware.com/go/powercli

ESX

Page 183: PowerCLI Workshop

Advanced Reporting.

Identifying performance bottlenecks. Searching and archiving log files. Mixing vSphere and Active Directory.

http://vmware.com/go/powercli

REPORTS

Page 184: PowerCLI Workshop

Demo

Identifying performance bottlenecks.

Key cmdlets: Get-Stat

http://vmware.com/go/powercli

REPORTS

Page 185: PowerCLI Workshop

3 Takeaways: Performance Bottlenecks.

Bottlenecks occur when too many things compete for too few things.

PowerCLI can identify resources that have too many competitors.

PowerCLI can also easily move these around to balance workloads.

http://vmware.com/go/powercli

REPORTS

Page 186: PowerCLI Workshop

Demo

Archiving Log Files.

Key cmdlets: Copy-DatastoreItem

http://vmware.com/go/powercli

REPORTS

Page 187: PowerCLI Workshop

3 Takeaways: Archiving Log Files.

Retaining log files is critical for audit and compliance.

Log files are rotated (a.k.a. deleted) regularly.

The number of log files retained is customizable through PowerCLI.

http://vmware.com/go/powercli

REPORTS

Page 188: PowerCLI Workshop

6 Advanced FAQs (with answers!)

How can I reconfigure all my alarms to send SNMP traps?

How to find and register missing VMs? How to report on RDM? How to change DNS servers for ESX? How do I schedule a PowerCLI script? How about a script to respond to an

alarm?http://vmware.com/go/powercli

TIPS

Page 189: PowerCLI Workshop

Demo

Updating vCenter alarms.

Key cmdlets: Get-View

http://vmware.com/go/powercli

TIPS

Page 190: PowerCLI Workshop

2 Takeaways: vCenter Alarms.

If you’re deploying a lot of vCenter instances, PowerCLI will consistently reconfigure alarms just the way you want them.

LucD has a great script to move alarms from one container to another.http://lucd.info/?p=1799

http://vmware.com/go/powercli

TIPS

Page 191: PowerCLI Workshop

Demo

Find and register missing VMs.

Key cmdlets: Get-VM Get-View Get-Childitem

http://vmware.com/go/powercli

TIPS

Page 192: PowerCLI Workshop

2 Takeaways: Registering VMs.

Unregistering a VM rather than deleting it is a very common problem. This leads to wasted resources.

Warning: If you have two vCenters sharing the same storage, you will get false positives!

http://vmware.com/go/powercli

TIPS

Page 193: PowerCLI Workshop

Demo

Reporting on RDM.

Key cmdlets: Get-VM Get-ScsiLun

http://vmware.com/go/powercli

TIPS

Page 194: PowerCLI Workshop

1 Takeaway: RDM Reporting.

This simple report will help you ensure RDM is only being used by VMs that need it.

http://vmware.com/go/powercli

TIPS

Page 195: PowerCLI Workshop

Demo

Changing ESX IP address and DNS server.

Key cmdlets: Set-VMHostNetwork Set-VMHostNetworkAdapter

http://vmware.com/go/powercli

TIPS

Page 196: PowerCLI Workshop

2 Takeaways: Changing ESX IP and DNS.

Setting IP and DNS is another essential component of deploying ESX.

The same PowerCLI command lets you set IP and DNS attributes.

http://vmware.com/go/powercli

TIPS

Page 197: PowerCLI Workshop

How to schedule PowerCLI scripts.

Alan Renouf has a great writeup.http://www.virtu-al.net/2009/07/10/running-

a-powercli-scheduled-task/

http://vmware.com/go/powercli

TIPS

Page 198: PowerCLI Workshop

3 vSphere killers to regularly check.

Are any VMs waiting for answers? Automatically scanning for

configuration issues. DRS clusters with configuration

problems.

http://vmware.com/go/powercli

TIPS

Page 199: PowerCLI Workshop

Running scripts in response to alarms.

Fully documented 5 step process on the PowerCLI blog.

http://blogs.vmware.com/vipowershell/2009/09/how-to-run-powercli-scripts-from-vcenter-alarms.html

http://vmware.com/go/powercli

TIPS

Page 200: PowerCLI Workshop

Questions?

Download today: http://vmware.com/go/powercli

http://vmware.com/go/powercli