PowerCLI Workshop
Upcoming SlideShare
Loading in...5
×
 

PowerCLI Workshop

on

  • 26,305 views

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

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

Statistics

Views

Total Views
26,305
Views on SlideShare
26,158
Embed Views
147

Actions

Likes
10
Downloads
1,428
Comments
4

6 Embeds 147

http://www.slideshare.net 104
http://kickmaleerie.blogspot.com 32
http://kickmaleerie.blogspot.co.uk 6
http://webcache.googleusercontent.com 2
http://kickmaleerie.blogspot.ch 2
http://www.techgig.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Hello Carter, you have published good stuff! THANKS!
    Though i would like to use the 'Demo' but am not able to do so. Can you please advise me in this so that i can use the 'Demo's'?

    Thanks so far,
    Jim
    Are you sure you want to
    Your message goes here
    Processing…
  • Hi Carter, thanks for the document. Very useful stuff!!
    I am not able to click on the demo? Can you please advise me in this?

    Thanks in advance,
    Jim
    Are you sure you want to
    Your message goes here
    Processing…
  • This is the ultimate in vSphere PowerCLI Training ! For folks that prefer an instructor led course
    VMware provides a new course for new PowerCLI users;

    Course Title: VMware vSphere Automation available in the VMware Training Catalog.
    2 Day instructor led training, organizations can also use their PSO credits for course.

    Links to course are on the PowrCLI Home Page vmware.com/go/powercli
    Are you sure you want to
    Your message goes here
    Processing…
  • Download the scripts at http://communities.vmware.com/docs/DOC-12014
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • This picture is an old time accounting department. Used to be tens or hundreds of mathematicians or statisticians would sit around doing calculations and double-checking figures.
  • These days spreadsheets do the work of hundreds of calculators, and nobody thinks twice about it. Technology enabled a shift. A fundamental change in the way people did things.
  • Demo Script: MostUsedCmdlets.ps1
  • Demo Script: ImportCSV.ps1
  • Demo Script: 5Minute.ps1
  • Demo Script: LargeProvisioning.ps1
  • Demo Script: LargeUpdate.ps1
  • Demo Script: Snapshots.ps1
  • Demo Script: HostProfiles.ps1
  • Demo Script: Clusters.ps1
  • Demo Script: VMotionStorageVMotion.ps1
  • Demo Script: ThinProvision.ps1
  • Demo Script: NFS.ps1
  • Demo Script: MoveVMNetwork.ps1
  • Demo Script: VirtualSwitch.ps1
  • Demo Script: GuestDisk.ps1
  • Demo Script: Waste.ps1
  • Demo Script: CustomAttributes.ps1
  • Demo Script: RolesPermissions.ps1
  • Demo Script: StatsIntro.ps1
  • Demo Script: TopVMHost.ps1
  • Demo Script: EventReports.ps1
  • Demo Script: VMLastPoweron.ps1
  • Demo Script: ReadableCode.ps1
  • Demo Script: MaxSpeed.ps1
  • Demo Script: ObjectExtensions.ps1
  • Demo Script: GetViewGetMember.ps1
  • No script for this demo.
  • Demo Script: GuestManagement.ps1
  • Demo Script: ChangeSwap.ps1
  • Demo Script: iSCSI.ps1
  • Demo Script: RDM.ps1
  • Demo Script: UnsharedVMs.ps1
  • Demo Script: RDM.ps1
  • Demo Script: QueueDepth.ps1
  • Demo Script: AdvancedSwitch.ps1
  • Demo Script: ESXAdvancedConfig.ps1
  • Demo Script: Licensing.ps1
  • Demo Script: FindBottlenecks.ps1
  • Demo Script: ArchiveLogfiles.ps1
  • Demo Script: Alarms.ps1
  • Demo Script: RegisterVMs.ps1
  • Demo Script: RDMReport.ps1
  • Demo Script: ESXDNS.ps1

PowerCLI Workshop PowerCLI Workshop Presentation Transcript

  • vSphere PowerCLI
    The best tool for automating vSphere
    http://vmware.com/go/powercli
  • 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
  • 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
  • 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
  • Financial analysis – then.
  • Financial analysis – now.
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • Intro To PowerShell
    http://vmware.com/go/powercli
  • Top 5 things to know about PowerShell.
    The purpose.
    The cmdlets.
    The pipeline.
    The platforms.
    The products.
    http://vmware.com/go/powercli
  • 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-programmers
    to automate.
    http://vmware.com/go/powercli
  • 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
  • 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-Process
    Get-VM myvm | Start-VM
    http://vmware.com/go/powercli
  • 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
  • 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
  • The top 9 most used cmdlets.
  • The top 9 most used operators.
  • 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
  • Most Used PowerShell Cmdlets and Operators.
    Demo
    http://vmware.com/go/powercli
  • 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
  • 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
  • Using Import-CSV.
    Key cmdlets:
    • Import-CSV
    • Export-CSV
    • Get-Content
    Demo
    http://vmware.com/go/powercli
  • 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
  • 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
  • Intro To PowerCLI
    http://vmware.com/go/powercli
  • Top 5 things to know about PowerCLI.
    The purpose.
    The cmdlets.
    Cmdlet Tetris.
    The products.
    The future.
    http://vmware.com/go/powercli
  • 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. Everything
    vCenter can do.
    http://vmware.com/go/powercli
  • 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
  • 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
  • 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
  • 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
  • Making sense of it all.
  • Where do you feel the most pain?
    Configuring and maintaining ESX hosts?
    VMs?
    Reporting?
    Performance analysis?
    Troubleshooting?
    http://vmware.com/go/powercli
  • Use Cases and Demos
    http://vmware.com/go/powercli
  • PowerCLI Support Matrix (4.0 U1) (Latest)
    Tips
    Windows Vista (32 and 64 bit)
    Windows 2003 (32 and 64 bit)
    Windows XP
    http://vmware.com/go/powercli
  • PowerCLI Support Matrix (4.1) (Future!)
    Tips
    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
  • 3 ways to connect.
    Tips
    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
    A 5-minute introduction to PowerCLI.
    Key cmdlets:
    • Connect-VIServer
    • Get-VMHost
    • Get-VM
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: 5 minute intro.
    Tips
    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
  • Get-TheMost out of “Help”
    Tips
    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
  • Get-TheMost out of “Get” cmdlets.
    Tips
    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 easier
    to just try it out.
    Demo.
    http://vmware.com/go/powercli
  • PowerCLI supports multiple connections.
    Tips
    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
  • The top 9 VM-related cmdlets.
    VMs
  • Managing VMs with PowerCLI.
    VMs
    Provisioning.
    Change / Update.
    Change its resource allocation (e.g. memory).
    Change its networking.
    Add/remove storage.
    VMware Tools.
    http://vmware.com/go/powercli
  • What challenges do you face around VMs?
    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
  • 3 ways to provision your VMs.
    VMs
    Creating blank VMs and PXE booting them.
    Clone a template.
    Clone a VM while running.
    http://vmware.com/go/powercli
  • VMs
    Provisioning at large scales.
    Key cmdlets:
    • New-VM
    • Get-Template
    • Get-OSCustomizationSpec
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Large-scale provisioning.
    VMs
    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
    Large-scale VM Updates.
    Key cmdlets:
    • Get-VM
    • Set-VM
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: VM Updates.
    VMs
    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
    Dealing with snapshots.
    Key cmdlets:
    • Get-Snapshot
    • Remove-Snapshot
    • Where-Object
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Snapshots.
    VMs
    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
  • The top 8 ESX-related cmdlets.
    ESX
  • Managing ESX with PowerCLI.
    ESX
    Provisioning (Host profiles or scripted)
    Change / Update.
    Storage.
    Network.
    Security, etc.
    Managing power and connection state.
    http://vmware.com/go/powercli
  • What challenges do you face deploying ESX?
    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
  • 2 ways to provision your ESX hosts.
    ESX
    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
    Dealing with Host Profiles.
    Key cmdlets:
    • Get-VMHostProfile
    • Apply-VMHostProfile
    • Test-VMHostProfileCompliance
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Host Profiles.
    ESX
    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
  • Why we cluster.
    ESX
    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
    Clustering your hosts for max availability.
    Key cmdlets:
    • New-Cluster
    • Set-Cluster
    • Move-VMHost
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: Clustering.
    ESX
    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
  • You can also automate DRS rules.
    ESX
    Key cmdlets:
    New-DrsRule
    Get-DrsRule
    Set-DrsRule
    Remove-DrsRule
    http://vmware.com/go/powercli
  • The top 9 storage-related cmdlets.
    Storage
  • Managing Storage with PowerCLI.
    Storage
    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
  • What challenges do you face around storage?
    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 VMotion is a snap.
    Storage
    Move-VM is a versatile command.
    If you use –Datastore you will Storage VMotion.
    http://vmware.com/go/powercli
  • Storage
    VMotion and Storage VMotion with Move-VM.
    Key cmdlets:
    • Move-VM
    • Get-VMHost
    • Get-Datastore
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Storage VMotion.
    Storage
    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
  • Save money with thin provisioning.
    Storage
    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
    Thin Provisioning.
    Key cmdlets:
    • New-VM
    • New-Harddisk
    • Set-Harddisk
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Thin Provisioning.
    Storage
    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
    Adding NFS Datastores to ESX.
    Key cmdlets:
    • New-Datastore
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: NFS Datastores.
    Storage
    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
  • The top 9 network-related cmdlets.
    Network
  • Managing Networking with PowerCLI.
    Network
    Adding or configuring VMKernel.
    Moving VMs between virtual switches.
    Configuring virtual switch policies.
    http://vmware.com/go/powercli
  • What challenges do you face around network?
    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
    Moving VMs between networks.
    Key cmdlets:
    • Get-NetworkAdapter
    • Set-NetworkAdapter
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: Changing VM Networks.
    Network
    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
    Configuring Consistent Virtual Switches.
    Key cmdlets:
    • New-VirtualSwitch
    • Get-VirtualSwitch
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Virtual Switches.
    Network
    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
  • The top 5 reporting cmdlets.
    Reports
  • Reporting with PowerCLI.
    Reports
    Three major categories of PowerCLI reports.
    Inventory-based reporting.
    Statistic-based reporting (i.e. performance)
    Event-based reporting.
    http://vmware.com/go/powercli
  • Reporting with PowerCLI.
    Reports
    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
  • Inventory-based reporting.
    Reports
    Relies on Get-* cmdlets as a starting point.
    Generally combined with Export-CSV or ConvertTo-Html.
    http://vmware.com/go/powercli
  • Report on your guest disk capacity.
    Reports
    Basic report.
    Sort by least % free space.
    Show all guests with <10% free space.
    http://vmware.com/go/powercli
  • Reports
    Reporting on Guest Disk Capacity.
    Key cmdlets:
    • Get-VM
    • Get-Harddisk
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Guest Disks.
    Reports
    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
  • 3 ways to report on wasted resources.
    Reports
    Orphaned VMDKs. – script not working now
    Unused VMs.
    ???
    http://vmware.com/go/powercli
  • Reports
    Reporting on Wasted Resources.
    Key cmdlets:
    • Get-ChildItem
    • ??
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Wasted Resources.
    Reports
    X1
    X2
    X3
    http://vmware.com/go/powercli
  • Reporting with custom attributes.
    Reports
    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
    Reporting with Custom Attributes.
    Key cmdlets:
    • Get-CustomAttribute
    • Get-Inventory
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Custom Attributes.
    Reports
    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
    Security reporting using roles and permissions.
    Key cmdlets:
    • Get-VIUser
    • Get-VIRole
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Roles and Permissions.
    Reports
    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
  • Statistic-based reporting.
    Reports
    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
  • Get-TheMost out of Get-Stat.
    Reports
    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
    Introduction to statistic-based reporting.
    Key cmdlets:
    • Get-Stat
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Reporting with Statistics.
    Reports
    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
  • Top 8 Most Interesting Statistics.
    Reports
  • Reports
    Most and least busy VMs and Hosts.
    Key cmdlets:
    • Get-Stat
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: Host and VM Usage.
    Reports
    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
  • Event-based reporting.
    Reports
    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
    Introduction to event-based reporting.
    Key cmdlets:
    • Get-VIEvent
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Event-based reporting.
    Reports
    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
    When was that VM powered on?
    Key cmdlets:
    • Get-VIEvent
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Determining VM Poweron Date.
    Reports
    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
  • You can get your VM’s log file too.
    Reports
    Get to know vmstore:
    Use Copy-DatastoreItem to bridge the gap between local and remote.
    http://vmware.com/go/powercli
  • This report will make your manager love you (in a completely legal way).
    Reports
    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
  • Stuff Alan’s Daily Report Will Tell You.
    Reports
    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
  • Sample Daily Report Output.
    Reports
  • The top 9 other cmdlets.
    Tips
  • Top 5 PowerCLI FAQs (With answers!)
    Tips
    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
  • Top 5 PowerCLI FAQs (With answers!)
    Tips
    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
  • Top 5 PowerCLI FAQs (With answers!)
    Tips
    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
  • Top 5 PowerCLI FAQs (With answers!)
    Tips
    How to get the VM’s UUID?
    Inside the view property config.uuid
    Get-VM | Select Name, { ($_ | Get-View).config.uuid }
    Or using object extensions (upcoming feature).
    Demo.
    http://vmware.com/go/powercli
  • Secure your scripts with these tips.
    Tips
    You can configure PowerShell to not run unsigned scripts.
    Set-ExecutionPolicyAllSigned
    PowerShell Plus has built-in script signing.
    http://vmware.com/go/powercli
  • 3 mistakes you need to avoid!
    Tips
    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 use
    Write-Output.
    http://vmware.com/go/powercli
  • 4 tips to make your scripts more readable
    Tips
    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
    Maximizing readability and maintainability.
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Readability.
    Tips
    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
    Speeding up your scripts.
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Speeding up your scripts.
    Tips
    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
  • 1 feature you absolutely need to know.
    Tips
    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
    Simplifying Reporting With Object Extensions.
    Key cmdlets:
    • New-VIObjectExtensionProperty
    • (Name subject to change)
    Demo (Future Features)
    http://vmware.com/go/powercli
  • 3 Takeaways: Object Extensions.
    Tips
    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
  • Learn to write a PowerShell Advanced Function
    Tips
    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
  • Learn to write a PowerShell Advanced Function
    Tips
    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
  • Anatomy of an advanced function.
    Tips
    functionAdvanced-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)
  • Sample advanced function: ESX Host Routes.
    Tips
    Demo.
    http://vmware.com/go/powercli
  • Resources
    http://vmware.com/go/powercli
  • 3 must-own resources:
    Tips
    Managing VMware Infrastructure with Windows PowerShell.
    vSphere 4.0 Quick Start Guide.
    VMware vSphere Pro Series Training.
    http://vmware.com/go/powercli
  • The “PowerCLI Bible”
    Tips
    http://vmware.com/go/powercli
  • Lots of PowerCLI Samples.
    Tips
    http://vmware.com/go/powercli
  • New training from TrainSignal!
    Tips
  • 6 Amazing Blogs to Follow:
    Tips
  • The most important resource of all:
    Tips
    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
  • By Sheer Coincidence.
    Tips
    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
  • Advanced Stuff!
    http://vmware.com/go/powercli
  • The vSphere API Stack.
    API
  • Managed objects and automation objects.
    API
    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
  • Explore the vSphere API with PowerCLI.
    API
    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
  • You can do anything with Get-View.
    API
    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
    Use Get-View and Get-Member to explore the API.
    Key cmdlets:
    • Get-View
    • Get-Member
    Demo
    http://vmware.com/go/powercli
  • 4 Takeaways: Get-View.
    API
    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
  • Surviving the vSphere API Documentation.
    API
    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
  • Surviving the vSphere API Documentation (cont)
    API
    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
  • Using “Project Onyx”.
    API
    Onyx is a code generator.
    Sits between vSphere Client and vCenter.
    Any UI click is automatically turned to code.
    http://vmware.com/go/powercli
  • “Project Onyx” Architecture.
    API
    ESX or vCenter
  • API
    Using Onyx.
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Onyx.
    API
    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
  • Advanced VM management topics.
    VMs
    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
  • 2 ways to manage your guests.
    VMs
    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
    Guest management.
    Key cmdlets:
    • Invoke-VMScript
    • Copy-GuestFile
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Guest Management.
    VMs
    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
  • More advanced guest management: Customizing the scripts.
    VMs
    Certain guest cmdlets can be completely re-wired by substituting their scripts.
    Script sources located at $env:PROGRAMFILESVMwareInfrastructurevSphere PowerCLIScripts
    http://vmware.com/go/powercli
  • VMs
    Changing swap and memory location.
    Key cmdlets:
    • Get-View
    Demo
    http://vmware.com/go/powercli
  • 4 Takeaways: Changing swap location.
    VMs
    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
  • Advanced storage management topics.
    Storage
    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
  • Adding iSCSI datastores.
    Storage
    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
    Adding iSCSI to your hosts.
    Key cmdlets:
    • Get-VMHostStorage
    • Get-ScsiLun
    • New-Datastore
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Using iSCSI.
    Storage
    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
  • Two types of storage for your VMs.
    Storage
    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
    Finding and mounting raw devices.
    Key cmdlets:
    • Get-ScsiLun
    • New-Harddisk
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Raw Devices.
    Storage
    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
    Find VMs on unshared storage.
    Key cmdlets:
    • Get-View
    • Get-Datastore
    • Get-VM
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Unshared VMs.
    Storage
    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
    Determining LUN Performance.
    Key cmdlets:
    • Get-Stat
    • Warning: Doesn’t work with NFS storage.
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: LUN Performance.
    Storage
    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
  • Configuring adapter queue depth.
    Storage
    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
    Configuring adapter queue depth.
    Key cmdlets:
    • Set-VMHostModule
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Queue Depth.
    Storage
    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
  • Advanced network management.
    Network
    Advanced switch and portgroup policies.
    Creating and updating your service consoles.
    http://vmware.com/go/powercli
  • Network
    Advanced Network Management.
    Key cmdlets XXX need demo copied to desktop:
    • Get-NicTeamingPolicy
    • Set-NicTeamingPolicy
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Advanced Network Management.
    Network
    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
  • Advanced ESX management.
    ESX
    ESX build scripts.
    Setting advanced configuration parameters.
    Licensing.
    http://vmware.com/go/powercli
  • ESX build scripts you can use.
    ESX
    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
    Advanced Host Options.
    Key cmdlets:
    • Set-VMHostAdvancedConfiguration
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Advanced Host Options.
    ESX
    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
    Licensing.
    Key cmdlets:
    • Get-View
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Licensing.
    ESX
    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
  • Advanced Reporting.
    Reports
    Identifying performance bottlenecks.
    Searching and archiving log files.
    Mixing vSphere and Active Directory.
    http://vmware.com/go/powercli
  • Reports
    Identifying performance bottlenecks.
    Key cmdlets:
    • Get-Stat
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Performance Bottlenecks.
    Reports
    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
    Archiving Log Files.
    Key cmdlets:
    • Copy-DatastoreItem
    Demo
    http://vmware.com/go/powercli
  • 3 Takeaways: Archiving Log Files.
    Reports
    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
  • 6 Advanced FAQs (with answers!)
    Tips
    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
    Updating vCenter alarms.
    Key cmdlets:
    • Get-View
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: vCenter Alarms.
    Tips
    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
    Find and register missing VMs.
    Key cmdlets:
    • Get-VM
    • Get-View
    • Get-Childitem
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: Registering VMs.
    Tips
    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
    Reporting on RDM.
    Key cmdlets:
    • Get-VM
    • Get-ScsiLun
    Demo
    http://vmware.com/go/powercli
  • 1 Takeaway: RDM Reporting.
    Tips
    This simple report will help you ensure RDM is only being used by VMs that need it.
    http://vmware.com/go/powercli
  • Tips
    Changing ESX IP address and DNS server.
    Key cmdlets:
    • Set-VMHostNetwork
    • Set-VMHostNetworkAdapter
    Demo
    http://vmware.com/go/powercli
  • 2 Takeaways: Changing ESX IP and DNS.
    Tips
    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
  • How to schedule PowerCLI scripts.
    Tips
    Alan Renouf has a great writeup.
    http://www.virtu-al.net/2009/07/10/running-a-powercli-scheduled-task/
    http://vmware.com/go/powercli
  • 3 vSphere killers to regularly check.
    Tips
    Are any VMs waiting for answers?
    Automatically scanning for configuration issues.
    DRS clusters with configuration problems.
    http://vmware.com/go/powercli
  • Running scripts in response to alarms.
    Tips
    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
  • Questions?
    Download today: http://vmware.com/go/powercli
    http://vmware.com/go/powercli