+ All Categories
Home > Education > VMworld Europe 2014: Taking Reporting and Command Line Automation to the Next Level with PowerCLI

VMworld Europe 2014: Taking Reporting and Command Line Automation to the Next Level with PowerCLI

Date post: 15-Jul-2015
Category:
Upload: vmworld
View: 67 times
Download: 1 times
Share this document with a friend
46
Transcript

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.

Welcome to PowerCLI 5.8 R1Even more automation awesomeness (Automness?)

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

Storage Policy Based Management (SPBM)Storage Profiles / Storage Policies / SPBM

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

SPBMDEMO

SPBM Code ExampleStorage

Best Practices

Best Practice: External Info

• Use external resources

• Link ESXi build – VMware Tools version

• VMware webpage

Best Practice: External Info

• Learn RegEx expressions !

• Use hash tables for storing information

Best Practice : External Info

Best Practice : External Info

• If you are behind a proxy

• Add the following

Best PracticesFrom Idea to Function

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

• We have a link through the CanonicalName

Best Practice: From Idea to Function

• Use a Where-clause to fetch the info

One off

Best Practice: From Idea to Function

• Use a calculated property

Combine

Best Practice: From Idea to Function

• Report for all RDM in the cluster

Generalise

Best Practice: From Idea to Function

• Optimise: Get-ScsiLun is expensive

– With hash table lookup: 40% faster

Optimise

Best Practice: From Idea to Function

• Create a function

Reusability

Best Practice: From Idea to Function

Share

• Share a function

BP: From Idea to Function

• Share as a moduleShare+

Best Practice: From Idea to Function

OVF/OVA Deployment EnhancementsDeploying is now easier

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

OVF/OVA DeploymentDEMO

Reporting

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

Stats Toolbox DEMO

Integration

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

IntegrationDEMO

CMDB Code Example

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)

Handle VMRC

and VIX in the

same way

Generates MOF file

Desired State Configuration (DSC)

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.


Recommended