VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive
-
Upload
vmworld -
Category
Technology
-
view
227 -
download
2
Transcript of VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive
![Page 1: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/1.jpg)
Automating Everything VMwarewith PowerCLI – Deep Dive
Alan Renouf, VMware, IncLuc Dekens, Eurocontrol
INF5211
#INF5211
![Page 2: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/2.jpg)
• 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
CONFIDENTIAL 2
![Page 3: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/3.jpg)
Agenda
Welcome &
Technical Preview
1 2
Desired State Configuration
3
Best Practices
4
Q&A
![Page 4: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/4.jpg)
Who are we?Alan RenoufProduct Line Manager, VMware
– vExpert– VMware Blog: http://blogs.vmware.com/PowerCLI/– Personal Blog: http://virtu-al.net/– Twitter: @alanrenouf
Luc DekensSystems Engineer, Eurocontrol Maastricht
– Personal Blog: http://lucd.info/– vExpert & PowerShell MVP– VMTN account: LucD– Twitter: @Lucd22
![Page 5: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/5.jpg)
![Page 6: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/6.jpg)
PowerCLI
Image Builder
vCloud Air
vCenter
ESX
Horizon Mirage
Horizon ViewSite
Recovery Manager
vCloud Director
vRealize Operations Manager
Update Manager
Storage
AutoDeploy
Hardware Information
PowerCLI – Technical PreviewOn
DemandVASANFSVAIO
![Page 7: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/7.jpg)
PowerCLI Technical Preview
PS> Tech-Preview
• 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
![Page 8: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/8.jpg)
Report, Integrate, Automate vROPs• Full Low Level API Access
• High Level Cmdlets to cover some use cases
• Retrieve Alerts
• Change Alerts
• Retrieve Users
• Retrieve Stats
• Retrieve Recommendations
• Full vSphere relationship mapping
Note: Supported with vROPs 6.x
What’s New?
Another product covered by PowerCLI
New module and product support for vRealize Operations
![Page 9: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/9.jpg)
Connection: Connect-OMServer , Disconnect-OMServer Alerts: Get-OMAlert, Get-OMAlertDefinition, Get-OMAlertSubType, Get-OMAlertType, Set-OMAlertRecommendations: Get-OMRecommendationResources: Get-OMResourceStats: Get-OMStat, Get-OMStatKey, Get-OMUser
vRealize Operations Cmdlets and Examples
Example PowerCLI code for some of the new vROPs cmdlets:
Retrieve a VM called Photon01 from vCenter and get its basic health information from vRealize Operations
C:\PS>Get-VM Photon01 | Get-OMResource
Retrieve metric data for Host01 from the last month aggregated on daily basis
C:\PS>Get-VMHost Host01 | Get-OMResource | Get-OMStat -Key "mem|waste" -From ([datetime]::Now.AddMonths(-1)) -IntervalType Days -IntervalCount 1 -RollupType Avg"
Find out what is wrong with Phton01 by listing the alerts related to the VM in a table
C:\PS>Get-VM Photon01 | Get-OMresource | Get-OMALert | FT -AutoSize
![Page 10: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/10.jpg)
VROPSDEMO
![Page 11: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/11.jpg)
11
vROPS example code
![Page 12: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/12.jpg)
vSphere Storage API Cmdlets• Register new VASA Providers
• List registered VASA Providers
• List storage arrays managed by registered VASA providers
• Unregister VASA Providers
NFS User Cmdlets• Create NFS user accounts on ESXi Hosts
• List NFS user accounts on ESXi Hosts
• Change NFS user accounts on ESXi Hosts
• Remove NFS user accounts on ESXi Hosts
vSphere API for IO Filtering• Update a VAIO filter on a cluster
What’s New?
Updated Storage Cmdlets
Updated Storage Module
Storage Module
VSAN
VASA
SPBMVAIO
NFS
![Page 13: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/13.jpg)
Updated Storage Cmdlets and Examples
Example PowerCLI code for some of the new Storage cmdlets:
Register a VASA provider by using the "MyCredential" credential and forcing the Storage Monitoring Service to accept the certificate of the provider.
C:\PS>New-VasaProvider -Name "MyProvider" -Credential "MyCredential" –Url "MyUrl" –Force
Create the "user1" NFS user account on the $vmhost virtual machine host and set the password to "password1“
C:\PS>New-NfsUser -VMHost $vmhost -Username "user1" -Password "password1"
Update the $filter VAIO filter and set the VIB URL to "NewVibUrl". The version of the new VIB should be higher than the existing filter version.
C:\PS>Set-VAIOFilter -Filter $filter -VibUrl "NewVibUrl"
New VASA Cmdlets : New-VasaProvider, Remove-VasaProvider, Get-VasaProvider and Get-VasaStorageArrayNew NFS User Cmdlets: New-NfsUser, Remove-NfsUser, Get-NfsUser and Set-NfsUserAdded VAIO filters Cmdlet: Set-VAIOFilter
![Page 14: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/14.jpg)
Updated cmdlets to connect to On-Demand• Manage both On-Demand and Dedicated
Resources
• Updated OrgVDCNetwork Cmdlet to make working with On-Demand easier
• All vCloud Air cmdlets work
• Work with both On-Premesis and Cloud through the same shell
• No need to relearn how to automate your infrastructure
What’s New?
Single pane of glass CLI Management!
vCloud Air Cmdlets now work with On-Demand (vCA)
VIRTUALMACHINES
ON-PREMISESDATA CENTER
vCLOUD AIR
VIRTUALMACHINES
VIRTUALMACHINES
VIRTUALMACHINES
VIRTUALMACHINES
VIRTUALMACHINES
VIRTUALMACHINES
VIRTUALMACHINES
POWERCLI CMDLETS
![Page 15: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/15.jpg)
vCloud AirDEMO
![Page 16: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/16.jpg)
16
Hybrid report example code
![Page 17: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/17.jpg)
17
Hybrid report example code - github.com/alanrenouf/vAudit-vCloudAir
![Page 18: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/18.jpg)
Easily list Host hardware information• 2 new cmdlets
• Get-VMHostHardware lists host information
• Get-VMHostPCIDevice lists all PCI Devices
• Instantly see host serial numbers and hardware details
• Check host hardware similarity in a cluster
• Compare the results to the HCL
What’s New?
List hardware information easily!
Host hardware information
![Page 19: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/19.jpg)
Host HardwareDEMO
![Page 20: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/20.jpg)
20
Host hardware example code
![Page 21: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/21.jpg)
Single installer to simplify installation• vSphere Update Manager module now included in
the core PowerCLI installer
• No more separate download and installer
• Support for multiple versions of VUM
• Backwards compatibility to VUM 5.5
Note: if using a VUM version previous to 5.5 you will need to install the VUM cmdlets separately
What’s New?
Now Included!
Update Manager now included in core installer
![Page 22: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/22.jpg)
Desired State ConfigurationScripted Resources
![Page 23: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/23.jpg)
DSC & vSphere• Go for PowerShell v5• What is needed ?• Pull or push ?• PS objects or classes ?• Where shall the vSphere resources be used ?• Implementation examples
– Resource definition– Resource assignment
• In practice: “Make it so!”• Complexity * Scale -gt What we can handle
![Page 24: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/24.jpg)
24
DSC & vSphere
1. Configure LCM to Pull2. Develop scripted resource
1. Get2. Set3. Test
3. Package as Resource Module1. ZIP & checksum Pull2. DSC Resource to Dev WS
4. Test functioning
![Page 25: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/25.jpg)
25
DSC & vSphere
![Page 26: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/26.jpg)
26
DSC & vSphere
![Page 27: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/27.jpg)
CONFIDENTIAL 27
DSC & vSphere
![Page 28: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/28.jpg)
Best PracticesWorking with REST API
![Page 29: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/29.jpg)
29
PowerShell and the REST API
• Why would I use a REST API ?• Can I do this from PowerShell ?
– PS v4: Invoke-RestMethod– Watch out: open connections limit set to 2
• Bypass: CloseConnectionGroup– JSON
• Convert built-in• DateTime objects are special
• Tools to help– Chrome – Advanced Rest Client– Fiddler
![Page 30: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/30.jpg)
REST API DEMO
![Page 31: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/31.jpg)
31
PowerShell and the REST API
![Page 32: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/32.jpg)
Best PracticesRegular Expression
![Page 33: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/33.jpg)
33
Question from the field: next suffix
• Names ending with a numeric suffix – calculate the next one– Start to use Select-String– …finally start learning RegEx
![Page 34: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/34.jpg)
Best PracticesHow to use these API methods and properties
![Page 35: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/35.jpg)
CONFIDENTIAL 35
TARGETED
More-Cmdlets
Get-DatastoreGet-VM
Get-View (Low Level)
HARDER TO USE FOR SYSADMINFAST
vSphere API
What is Get-View and .extensiondata?
.Net View of APIs (100% PUBLIC)
Cmdlets (High Level)
.ExtensionData Property
$spec = new-object VMware.Vim.VirtualMachineConfigSpec$spec.MemoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo$spec.MemoryAllocation.Limit = -1$vm = get-view -ViewType VirtualMachine -Filter @{"Name"="VM001"}$vm.ReconfigVM_Task($spec)
Get-VM VM001 | Get-VMResourceConfiguration | `Set-VMResourceConfiguration -MemLimitMB $null
![Page 36: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/36.jpg)
API
• Question keeps coming back• Another (quick) example: activate VDS health script• Method 1:
– API Reference• Yes, there is a logic in there!
– Follow the trail– Find the method
• Method 2: – Onyx Web Client– What do you get ?– How to use it ?
![Page 37: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/37.jpg)
API : Method 1 – Books and Logic
<Ctrl>-F
![Page 38: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/38.jpg)
API : Method 2
![Page 39: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/39.jpg)
![Page 40: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/40.jpg)
![Page 41: VMworld 2015: Automating Everything VMware with PowerCLI- Deep Dive](https://reader036.fdocuments.in/reader036/viewer/2022062522/589c1f6a1a28ab007e8b701b/html5/thumbnails/41.jpg)
Automating Everything VMwarewith PowerCLI – Deep Dive
Alan Renouf, VMware, IncLuc Dekens, Eurocontrol
INF5211
#INF5211