vmworld 2015: day to day automation of vmware products to increase productivity and efficiency

57
Day to Day Automation of VMware Products to Increase Productivity and Efficiency Brian Graf, VMware, Inc INF4793 #INF4793

Upload: vmworld

Post on 11-Feb-2017

164 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

Day to Day Automation of VMware Productsto Increase Productivity and Efficiency

Brian Graf, VMware, Inc

INF4793

#INF4793

Page 2: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 3: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 4: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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?

Page 5: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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.

Page 6: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 7: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 8: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 9: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Use Cases

Page 10: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 11: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 12: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

CONFIDENTIAL 12

Page 13: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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…

Page 14: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 15: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 16: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics – Connect to vCenterPowerCLI Command:

Connect-VIServer –Server 10.144.99.9 –User [email protected]

17CONFIDENTIAL

Page 17: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Command: New-VICredentialStoreItem –Host 10.144.99.9 `–user [email protected] –password vmware1!

Get-VICredentialStoreItem

PowerCLI Basics – Store vCenter Credentials

18CONFIDENTIAL

Page 18: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics

Get-VMPowerCLI Command:

19CONFIDENTIAL

Page 19: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics

Get-VM -Name “MGMT*"PowerCLI Command:

20CONFIDENTIAL

Page 20: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics

(Get-VM).CountPowerCLI Command:

21CONFIDENTIAL

Page 21: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics – Datastores

Get-DatastorePowerCLI Command:

22CONFIDENTIAL

Page 22: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

CONFIDENTIAL

PowerCLI Basics - Datastores

Get-Datastore –name GreenPowerCLI Command:

23

Page 23: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics - Datastores

$ds = Get-Datastore –name GreenPowerCLI Command:

Get-VM -Datastore $ds | Start-VM

24CONFIDENTIAL

Page 24: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics – Finding CommandsPowerCLI Command:

Get-Command *VM*

25CONFIDENTIAL

Page 25: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI Basics – Getting HelpPowerCLI Command:

Get-Help New-VM -Examples

26CONFIDENTIAL

Page 26: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 27: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

DEMO – Using what we’ve learned

Page 28: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 29: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 30: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

PowerCLI GUI’s?!

Page 31: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 32: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

CONFIDENTIAL 33

There is a Time and Place for Everything…

Page 33: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

GUI Demo/Example

Page 34: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

VMware ProductsAnd how PowerCLI can work with them

Page 35: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

vCloud Air CmdletsExtensibility of High-Level Cmdlets to the cloud

Page 36: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 37: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 38: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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:

Page 39: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

VSAN Cmdlets

Page 40: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 41: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 42: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

vRealize Operations

Page 43: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 44: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

Site Recovery ManagerLow-Level API access

Page 45: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 46: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

VMware NSXREST API calls from PowerCLI

Page 47: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 48: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

What’s New – Tech Preview

Page 49: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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?

Page 50: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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?

Page 51: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 52: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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

Page 54: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

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.

Page 55: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency
Page 56: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency
Page 57: VMworld 2015: Day to Day Automation of VMware Products to Increase Productivity and Efficiency

Day to Day Automation of VMware Productsto Increase Productivity and Efficiency

Brian Graf, VMware, Inc

INF4793

#INF4793