vmworld 2015: day to day automation of vmware products to increase productivity and efficiency
TRANSCRIPT
Day to Day Automation of VMware Productsto Increase Productivity and Efficiency
Brian Graf, VMware, Inc
INF4793
#INF4793
CONFIDENTIAL 2
• This presentation may contain product features that are currently under development.
• This overview of new technology represents no commitment from VMware to deliver these features in any generally available product.
• Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind.
• Technical feasibility and market demand will affect final delivery.
• Pricing and packaging for any new technologies or features discussed or presented have not been determined.
Disclaimer
Who Am I?
• Brian Graf– Senior Technical Marketing Manager – Vmware– PowerCLI Automation, ESXi Lifecycle, ROBO
• vExpert, VCAP5-DCA/DCD• VMware Blog: http://blogs.vmware.com/PowerCLI/• Personal Blog: http://www.vtagion.com• Twitter: @vBrianGraf
3CONFIDENTIAL
CONFIDENTIAL 4
Agenda
1Getting Started• Background• Who is PowerCLI for? No, but really…
2PowerCLI Use Cases• What do people use PowerCLI for?• Why should YOU use PowerCLI?• Examples and demos of PowerCLI in action.
3 Performance• What’s coming in the next release?
CONFIDENTIAL 5
INF4793Many of us have become very comfortable in performing tasks manually in the desktop client or the vSphere Web Client, but doing things manually will always take more time and be more prone to errors, as opposed to automating them. Come learn how easy our automation solution is and how you can start automating actions, reports, and processes in your virtual environment today! We will discuss how to perform bulk actions against objects in the environment, create fast and valuable reports, and how to move away from all the manual and redundant tasks. If you do something more than once, you should automate it. If you are a PowerCLI beginner or haven’t even tried PowerCLI this session is for you. Stop wasting your time and learn how to reclaim your day, the PowerCLI way.
INF4793Many of us have become very comfortable in performing tasks manually in the desktop client or the vSphere Web Client, but doing things manually will always take more time and be more prone to errors, as opposed to automating them. Come learn how easy our automation solution is and how you can start automating actions, reports, and processes in your virtual environment today! We will discuss how to perform bulk actions against objects in the environment, create fast and valuable reports, and how to move away from all the manual and redundant tasks. If you do something more than once, you should automate it. If you are a PowerCLI beginner or haven’t even tried PowerCLI this session is for you. Stop wasting your time and learn how to reclaim your day, the PowerCLI way.
Microsoft® PowerShell™ – Overview• Microsoft PowerShell is the foundation of PowerCLI
• The best shell today for Windows Environments– Easy to learn and understand– Built for system administrators, not for programmers– Object Orientated– Extended to the entire Datacenter
• Microsoft is serious about it– So is VMware
6CONFIDENTIAL
PowerCLI – Overview• Command line tool that leverages Microsoft PowerShell
• The best shell for automating and managing your virtual environment– Follows PowerShell syntax and command verbs– Almost 500 cmdlets for working with vSphere environments– 10+ Products and technologies, and more to come!– PowerCLI 6.0 is backwards compatible to vSphere 5.0– No license required– Improved through community feedback
7CONFIDENTIAL
Who is Powercli Meant For?
CONFIDENTIAL 8
Basic Admins Advanced Admins Developers Management
Day-to-day Administration
Work with vSphere API
Create .NET Applications Reporting
Mass Configuration Changes
Create Advanced Functions DevOps Auditing
Health reports Parallel Jobs GUI / App Overlays Forecasting
PowerCLI Use Cases
What Do People Use Powercli For?
Save time through automation
Simplify automated tasks and user workflows
Diagnose, explore and resolve issues
Make large scale changes in a consistent and auditable way
Produce customized reporting
10CONFIDENTIAL
11
Produce Customized Reporting– Complex queries for the entire SDDC
• Combination of data from VMware & 3rd party software and hardware
– Output usage information for license purposes– Create audit reports for best practices– Export configuration information– Security Auditing (See Hardening Guide)
Get-VM | Select-Object Name, NumCPU, MemoryMB, PowerState, Host | Export-CSV Simple_Inventory.csv -NoTypeInformation
CONFIDENTIAL
CONFIDENTIAL 12
CONFIDENTIAL 13
Reporting – What Should I Report?• General Details
– # of Hosts– # of VMs– # of Templates– # of Clusters– # of Datastores– # of Active VMs– # of Inactive VMs– # of DRS Migrations for the last days
• VM Details– VMs created over the last x days– VMs removed over the last x days– VMs with no Tools installed– VMs with CD-Roms connected– VMs with Floppy Drives Connected– VMs with CPU ready over x%– VMs with over x amount of vCPUs
• Host Details– Hosts in Maintenance Mode– Hosts in disconnected state– NTP Server check for a given NTP
Name– NTP Service check– Host active Alerts– ESXi hosts without Lockdown
enabled– ESXi hosts with unsupported mode
enabled
• And much much more…
14
Save Time Through Automation
We enable our customers to:– Remove the “Human Error Aspect” by enabling them to
produce repeatable tested scripts– Manage VMware and 3rd Party software and hardware– Provide automation tasks that are not native to the product– Quickly produce Prototype tools
CONFIDENTIAL
15
Make Large Scale Changes in a Consistent and Auditable Way
• We enable our customers to configure multiple VMware SDDC Environments from the same interface
• Easily define changes and execute them in large scale environments
• Deploy new VMware products and features
Customers no longer manage 1 or 10 Servers, its often 100s or 1000s
vCloud Air
CONFIDENTIAL
PowerCLI Basics – Connect to vCenterPowerCLI Command:
Connect-VIServer –Server 10.144.99.9 –User [email protected]
17CONFIDENTIAL
PowerCLI Command: New-VICredentialStoreItem –Host 10.144.99.9 `–user [email protected] –password vmware1!
Get-VICredentialStoreItem
PowerCLI Basics – Store vCenter Credentials
18CONFIDENTIAL
PowerCLI Basics
Get-VMPowerCLI Command:
19CONFIDENTIAL
PowerCLI Basics
Get-VM -Name “MGMT*"PowerCLI Command:
20CONFIDENTIAL
PowerCLI Basics
(Get-VM).CountPowerCLI Command:
21CONFIDENTIAL
PowerCLI Basics – Datastores
Get-DatastorePowerCLI Command:
22CONFIDENTIAL
CONFIDENTIAL
PowerCLI Basics - Datastores
Get-Datastore –name GreenPowerCLI Command:
23
PowerCLI Basics - Datastores
$ds = Get-Datastore –name GreenPowerCLI Command:
Get-VM -Datastore $ds | Start-VM
24CONFIDENTIAL
PowerCLI Basics – Finding CommandsPowerCLI Command:
Get-Command *VM*
25CONFIDENTIAL
PowerCLI Basics – Getting HelpPowerCLI Command:
Get-Help New-VM -Examples
26CONFIDENTIAL
Taking Action! – Modifying Bulk Objects
27
Get-VMHost | Add-VMHostNtpServer 198.60.73.8
Get-VMHost | Get-VMHostFirewallException | where ` {$_.Name -eq "NTP client"} | `Set-VMHostFirewallException -Enabled:$true
Get-VMHost | Get-VmHostService | Where-Object ` {$_.key -eq "ntpd"} | Start-VMHostService
Get-VMhost | Get-VmHostService | Where-Object ` {$_.key -eq "ntpd"} | Set-VMHostService -policy "automatic"
CONFIDENTIAL
DEMO – Using what we’ve learned
Mass Portgroup Migration
$Cluster = "Staging" $CurrentPG = "vDS-Staging01" $NewPG = "vDS-Staging02"
Get-Cluster $Cluster | Get-VM | Get-NetworkAdapter | `Where {$_.NetworkName -eq $CurrentPG } | Set-NetworkAdapter `-NetworkName $NewPG -Confirm:$false
PowerCLI Command:
vSphere Distributed SwitchvDS-Staging01 vDS-Staging02
29CONFIDENTIAL
30
Diagnose, Explore and Resolve Issues• We enable our customers to
• Resolve problems that can not be solved through the UI– Exploration -> Diagnoses -> Resolution
• Access Physical Console diagnostics (ESXCLI)
• Easily step through their troubleshooting process
CONFIDENTIAL
PowerCLI GUI’s?!
There is a Time and Place for Everything…• Larger actions are taking place
• More sophisticated queries / settings that would result in a very long function
• Interaction within the scripts
• The user is uncomfortable working in a CLI
32CONFIDENTIAL
CONFIDENTIAL 33
There is a Time and Place for Everything…
GUI Demo/Example
VMware ProductsAnd how PowerCLI can work with them
vCloud Air CmdletsExtensibility of High-Level Cmdlets to the cloud
37
New in PowerCLI 6.0: Manage vCloudAir• Manage On-Premises and vCloud air in the same console
• 100+ Cmdlets to work with the Cloud
• “Tenant” PowerCLI removed
• Optional Install in PowerCLI
• Connect to multiple Clouds
• Get-CIView gives entire public API
• Store credentials for easy connection
• Report• Troubleshoot• Automate
vCloud AIr
CONFIDENTIAL
New in PowerCLI 6.0: Manage vCloud Air
Example PowerCLI code for some of the new vCloud Air cmdlets: Connect to default vCloud Air Instance
Connect-PIServer –Username [email protected] –Password VMware1!
List all vCloud Air Datacenters you have access to
Get-PIDatacenter
Connect to all vCloud Air Datacenters you have access to
Get-PIDatacenter | Connect-PIDatacenter
Connect-PIServerDisconnect-PIServerGet-PIDatacenter
Cmdlets:“CI” Cmdlets now have a “PI” Alias and work with vCloud Air
Updated Cmdlets:
vCloud AIr
38CONFIDENTIAL
Manage vCloud Air
Connect-PIServerDisconnect-PIServerGet-PIDatacenter
Cmdlets:“CI” Cmdlets now have a “PI” Alias and work with vCloud Air
Updated Cmdlets:
vCloud AIr
39CONFIDENTIAL
Example PowerCLI code for some of the new vCloud Air cmdlets:
VSAN Cmdlets
New in PowerCLI 6.0: VSAN Cmdlets
Example PowerCLI code for some of the new VSAN cmdlets:Enable the VSAN VMKernel Network for a host
Get-VMHost Host1 | Get-VMHostNetworkAdapter -VMKernel | Where {$_.PortGroupName -eq "Management Network" } | Set-VMHostNetworkAdapter -VsanTrafficEnabled $true -Confirm:$false
Enable VSAN on Cluster1 and set to Automatic Disk Claim Mode
Get-Cluster Cluster1 | Set-Cluster -VsanEnabled:$true -VsanDiskClaimMode Automatic -Confirm:$false
List Hosts and Disk Groups
Get-VsanDiskGroup | Select VMHost, Name | FT -AutoSize
Get-VsanDiskNew-VsanDiskRemove-VsanDisk
Cmdlets:Get-VsanDiskGroupNew-VsanDiskGroupRemove-VsanDiskGroup
New-ClusterSet-Cluster
Updated Cmdlets:New-VMHostNetworkAdapterSet-VMHostNetworkAdapter
41CONFIDENTIAL
New in PowerCLI 6.0: VSAN Cmdlets
Example PowerCLI code for enabling VSAN:
Get-VsanDiskNew-VsanDiskRemove-VsanDisk
Cmdlets:Get-VsanDiskGroupNew-VsanDiskGroupRemove-VsanDiskGroup
New-ClusterSet-Cluster
Updated Cmdlets:New-VMHostNetworkAdapterSet-VMHostNetworkAdapter
42CONFIDENTIAL
vRealize Operations
vRealize Operations Cmdlets
Example PowerCLI code for some of the new vRealize Operations cmdlets:
New Cmdlets:
44CONFIDENTIAL
Get-OMAlertGet-OMAlertDefinitionGet-OMAlertSubTypeGet-OMAlertType
Get-OMRecommendationGet-OMResourceGet-OMStatGet-OMStatKey
Get-OMUserSet-OMAlertConnect-OMServerDisconnect-OMServer
# Connect to vRealize Operations ManagerConnect-OMServer 10.134.14.26 -user administrator -password VMware1!
# Get current Alerts$alert = Get-OMAlert
# Get the Alert DefinitioinsGet-OMAlertDefinition -Name $alert
Site Recovery ManagerLow-Level API access
Site-Recovery Manager
Example PowerCLI code advanced SRM:
$SrmConnection = Connect-SrmServer 10.20.181.32
$SrmConnection | Get-Member $SrmApi = $SrmConnection.ExtensionData $SrmApi $SrmApi.Recovery.ListPlans()
Connect-SRMServerDisconnect-SRMServer
Cmdlets:
Leverages Site Recovery Manager API
46CONFIDENTIAL
VMware NSXREST API calls from PowerCLI
Cmdlets for NSX?
Example PowerCLI code advanced NSX functions: $Credential = Get-CredentialConnect-NSXManager -NSXIP 10.144.99.22 -NSXPassword VMware1! -vCIP 10.144.99.15 -Credential $Credential
# --- Create REST Headers $Auth = "admin" + ':' + $NSXPassword $Encoded = [System.Text.Encoding]::UTF8.GetBytes($Auth) $EncodedPassword = [System.Convert]::ToBase64String($Encoded) $Headers = @{"Authorization"="Basic $($EncodedPassword)";} # --- Send REST call and process results
$uri = "https://$NSXIP/api/2.0/services/vcconfig"$body = "<vcInfo><ipAddress>$vCIP</ipAddress>" $body += "<userName>$vcuser</userName><password>"$body += "$vcpass</password></vcInfo>"
There are none
Cmdlets:
48CONFIDENTIAL
What’s New – Tech Preview
PowerCLI
Image Builder
vCloud Air
vCenter
ESX
Horizon Mirage
Horizon ViewSite
Recovery Manager
vCloud Director
vRealize Operations Manager
Update Manager
Storage
AutoDeploy
Hardware Information
On Demand
VASANFSVAIO
PowerCLI Tech Preview – What’s New?
PS> Whats-New
• New module and product support for vRealize Operations• Even more storage management and automation with:
• vSphere Storage API Cmdlets• NFS User Cmdlets• Updated vSphere API for IO Filtering Cmdlets
• Connect and manage On-Demand resources in vCloud Air• Updated vCloud Air Cmdlets for networking• Host hardware information• Update Manager now included in core installer for simpler and quicker deployment• Updated Support for SRM 6.1• Licensing Snapin converted to Module
PowerCLI Tech Preview – What’s New?
52
Tech Preview
CONFIDENTIAL
New Cmdlets: New Cmdlets: New Cmdlets:
Operations Manager:Get-OMAlertGet-OMAlertDefinitionGet-OMAlertSubTypeGet-OMAlertTypeGet-OMRecommendationGet-OMResourceGet-OMStatGet-OMStatKeyGet-OMUserSet-OMAlert
Host Info:Get-VMHostHardwareGet-VMHostPciDevice
Storage:Get-VAIOFilterSet-VAIOFilterGet-VasaProviderGet-VasaStorageArrayNew-VasaProviderRemove-VasaProvider
NFS 4.1:Get-NfsUserNew-NfsUserRemove-NfsUserSet-NfsUser
vCloud Air/On-Demand:Connect-PIComputeInstanceDisconnect-PIComputeInstanceGet-OrgVdcNetworkGet-PIComputeInstanceGet-PIDatacenter
What Now?:7 Question PowerCLI Survey: http://bit.ly/powerclisurvey
Download PowerCLI 6.0 R1 Now!: http://bit.ly/PowerCLI6r1
PowerActions
Onyx for Web Client
Download PowerCLI reference poster (PDF): http://bit.ly/PowerCLIPosterv2
Learn More:@PowerCLI
@vBrianGraf
Blog: http://blogs.vmware.com/PowerCLI
Facebook: https://www.facebook.com/vmwarepowercli
LinkedIn: https://www.linkedin.com/groups/PowerCLI-Users-162324/about
VMware Communities: https://communities.vmware.com/community/vmtn/automationtools/powercli
55CONFIDENTIAL
justingrote says:PowerShell saved me so much time
PeterVG says:Thanks a million, you saved me a lot of time!!
sddunne says:This works excellently and has saved our Bacon!
packetboy says:you saved me heaps of time! thanks!!
tonygent says:You’ve saved me hours :)
sepeck says:Just saved my co-workers a bunch of work on the next patch cycle.
johnwilk says:you have just saved me a weeks work.
RagingOtter says:Thanks for posting this it saved me a lot of time
rbrannigan says:If I ever manage to find a girlfriend I’ll have tons of time to spend with her thanks to PowerCLI.
Day to Day Automation of VMware Productsto Increase Productivity and Efficiency
Brian Graf, VMware, Inc
INF4793
#INF4793