Disclaimer
• 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.
CONFIDENTIAL 2
Lets talk PowerCLI• Introduction
• Welcome to PowerCLI 5.8 R1
• Best Practices
From one line to a full script
• Deployment
• Reporting
Statistical Reporting
SRM Reporting
vCloud Reporting
• Integration
SDDC Integration
Desired State Configuration
Who are we?
Brian GrafTechnical Marketing - Automation, VMware
vExpert
VMware Blog: http://blogs.vmware.com/PowerCLI/
Personal Blog: http://www.vtagion.com
Twitter: @vTagion
Luc DekensSystems Engineer, Eurocontrol Maastricht
Personal Blog: http://lucd.info/
vExpert & PowerShell MVP
VMTN account: LucD
Twitter: @Lucd22
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.
Image
Builder
Auto Deploy
License
vCloud
Director
vCloud
Tenant
vSphere
Distributed
Switch
Site
Recovery
Manager
vSphere
Core
PowerCLI – 5.8 R1 What's New?
Storage
PowerCLI – 5.8 R1 What's New?
• Enhanced startup speed
• Storage Policy cmdlets
• Query an OVF/OVA for deployment properties
• OVF/OVA deployment and configuration
• Added a filter by tag to more cmdlets
• Enhanced error reporting
• Added support for RelatedObject to Get-HardDisk
• Added filtering support to multiple areas
• Support for latest version of vCloud APIs
• New-CIVM cmdlet
• Support for upcoming version of SRM
PS> Whats-New
New Storage Snapin
New Cmdlets to work with Storage Policy Based ManagementStorage
• Set-SpbmStoragePolicy
• Remove-SpbmStoragePolicy
• New-SpbmStoragePolicy
• Get-SpbmStoragePolicy
• Export-SpbmStoragePolicy
• Import-SpbmStoragePolicy
• Get-SpbmCapability
• Get-SpbmCompatibleStorage
• Get-SpbmEntityConfiguration
• Set-SpbmEntityConfiguration
• New-SpbmRule
• New-SpbmRuleSet
• Get-SpbmView
New Storage Snapin Examples
Example PowerCLI code for some of the new SPBM cmdlets:
Return all SPBM capability schemas which belong to the "VSAN" namespace and are of category "Performance"
C:\PS>Get-SpbmCapability –Namespace "VSAN" –Category "Performance"
Create a new storage policy named "MyPolicy", with description "MyPolicyDescription" and with rule set objects
$ruleset1, $ruleset2 and $ruleset3.
C:\PS>New-SpbmStoragePolicy –Name "MyPolicy" –Description "MyPolicyDescription" –AnyOfRuleSets$ruleset1, $ruleset2, $ruleset3
Deploying a New VM named “VM1” to a storage Policy named “GoldPolicy”:
C:\PS>New-VM –Name VM1 –VM base-sles-01a –Datastore (Get-SpbmCompatibleStorage –StoragePolicyGoldPolicy) –VMHost esx-01a.corp.local –DiskStorageFormat thin
Storage
Best Practice: External Info
• Use external resources
• Link ESXi build – VMware Tools version
• VMware webpage
Best Practice: From Idea to Function
• How do we get to some of the scripts
• Scripts are organic
• Multiple stages
– One-off, quick solution
– A working solution
– An optimised solution
– A reusable solution
– A shareable solution
Best Practice: From Idea to Function
• Problem : show multipath policy for RDMs
• Find where the information is
– Get-Harddisk –Disktype
– Get-ScsiLun
Initial idea
Best Practice: From Idea to Function
• Optimise: Get-ScsiLun is expensive
– With hash table lookup: 40% faster
Optimise
OVF/OVA Deployment
OVF/OVA Parameters can now be set and passed in PowerCLI
Populate an OvfConfiguration object and provide it to Import-VApp. The populated OvfConfiguration object specifies
explicit values for one network mapping property and two standard properties.
$ovfConfig = Get-OvfConfiguration "myOvfTemplate.ovf"$ovfConfig.NetworkMapping.Network.Value = "Network 2"$ovfConfig.vami.VM_1.ip0.Value = "10.23.101.2"$ovfConfig.vami.VM_2.ip0.Value = "10.23.101.3"
Import-VApp $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost
Populate an OvfConfiguration object and provide it to Import-VApp. The populated OvfConfiguration object specifies a
network mapping by standard port group.
$ovfConfig = Get-OvfConfiguration "myOvfTemplate.ovf"$portGroup = Get-VirtualPortGroup -Name "Network 2" -Standard$ovfConfig.NetworkMapping.Network.Value = $portGroup
Import-VApp $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost
Reporting
vSphere Reporting
• Best place to start (safe)
• Community samples
• vCheck
SRM Reporting
• 5.5 R2 Introduced cmdlets
• 5.8 R1 adds more functionality
• Ken’s posts on vSphere Blog
vCloud Reporting
• Cloud cmdlets
• Tenant Snapin
• Updated in 5.8 R1
Statistical Reporting
• Get-Stat, Get-StatInterval
• Enhanced in 5.5 R2
• Stats Toolbox
Stats Toolbox
• A handy tool to explore the vSphere counters
• List by group and interval
• Change the statistics level
• Search the Internet
• What are the oldest available metrics
• Generate PowerCLI code
Integration
PowerShell makes integration easy
• Microsoft
• Common framework criteria
• 3rd Party
• NetApp / PernixData / Tintri / HP / More…
Rest API
• Invoke-RestMethod
• Invoke-Webrequest
Read from files
• XML
• CSV
• TXT
CMDB to vSphere Tags
Desired State Configuration (DSC)
• Introduced with PS v4
• Two modes: push & pull
• Main Purpose: capture configuration drift
• But also:
– initial deployment
– monitoring
• Built-in resources (Linux in CTP)
• Scripted resources (use PowerCLI)
ConclusionJoin PowerCLI-Dating.com to find your PowerCLI partner
rbrannigan says:
If I ever manage to find a girlfriend I’ll have tons
of time to spend with her thanks to PowerCLI.