20
PowerCLI for the PowerShell Inclined Josh Atwell vtesseract.com #vBrownBag Podcast @Josh_Atwell #RTPSUG / @RTPSUG

PowerCLI for the PowerShell Inclined

Embed Size (px)

DESCRIPTION

An introduction to PowerCLI for folks who already have familiarity with PowerShell. I touch on fundamentals of PowerCLI cmdlets and some little known gems. This presentation was presented to the RTP PowerShell Users Group on 2/19/2014.

Citation preview

Page 1: PowerCLI for the PowerShell Inclined

PowerCLI for the PowerShell Inclined

Josh Atwellvtesseract.com

#vBrownBag Podcast@Josh_Atwell#RTPSUG / @RTPSUG

Page 2: PowerCLI for the PowerShell Inclined

@josh_atwell - @rtpsug

Page 3: PowerCLI for the PowerShell Inclined

Get-Agenda• What is PowerCLI• Getting Started• Managing vSphere Environment• Get-View and .ExtensionData• Managing Update Manager (VUM)• Project Onyx

@josh_atwell - @rtpsug

Page 4: PowerCLI for the PowerShell Inclined

What is PowerCLI

www.vmware.com/go/powercli

Windows PowerShell for VMware Virtual Infrastructure and components

PowerCLI Admin Guide

@josh_atwell - @rtpsug

Page 5: PowerCLI for the PowerShell Inclined

PowerCLI Capabilities

@josh_atwell - @rtpsug

Page 6: PowerCLI for the PowerShell Inclined

First CommandsGet-PowerCLIConfiguration

Set-PowerCLIConfiguration –DefaultVIServerMode ‘multiple’

Get-PowerCLIVersion

@josh_atwell - @rtpsug

Page 7: PowerCLI for the PowerShell Inclined

Connecting

Connect-VIServer$cred = Get-CredentialConnect-VIserver –Credential $cred

Multiple Ways to ConnectConnect-VIserver –AllLinkedConnect-Viserver –Menu

$DefaultVIServer

@josh_atwell - @rtpsug

Page 8: PowerCLI for the PowerShell Inclined

Get-View• Returns the vSphere .Net view objects

• Filters!

• Methods

• Check out vNugglets.com@josh_atwell - @rtpsug

Page 9: PowerCLI for the PowerShell Inclined

Get-View Filters$filter = @{“Name” = “VMName”}Get-View –ViewType “VirtualMachine” –Filter $filter

@josh_atwell - @rtpsug

Page 10: PowerCLI for the PowerShell Inclined

Get-View and Methods

Test-vMotion

$si = Get-View ServiceInstance -Server $global:DefaultVIServer $VmProvCheck = get-view $si.Content.VmProvisioningChecker

$result = $VmProvCheck.CheckMigrate( $vmMoRef, $hsMoRef, $pool, $null, $null )

@josh_atwell - @rtpsug

VM MoRefID Host MoRefID Resource Pool MoRefID

Page 11: PowerCLI for the PowerShell Inclined

.ExtensionData

Let’s say you need a VM and what host and MoRef that VM is on

$vm.Vmhost$vm.ExtensionData.MoRef.Value$vm.ExtensionData.ResourcePool.Value

@josh_atwell - @rtpsug

Page 12: PowerCLI for the PowerShell Inclined

Browse Datastores - Hard

Use of PSDrives for browsing datastores

$datastore = Get-Datastore “Name”$psdrivename = $datastore.name

New-PSDrive -Name $psdrivename -PSProvider VimDatastore -Root / -Location $datastore

Get-Childitem ($psdrivename + “:/”)

Remove-PSdrive -name $psdrivename -Confirm:$false

@josh_atwell - @rtpsug

Page 13: PowerCLI for the PowerShell Inclined

Browse Datastores - Easy

• vi = Inventory of current VIServer• vis = Inventory of All connected VIServers

• cd vi:• dir (alias for Get-ChildItem)

– will give you what is in that root directory• dir –recurse

– gives all objects including subfolders

P. 28 of PowerCLI Admin Guide

@josh_atwell - @rtpsug

Page 14: PowerCLI for the PowerShell Inclined

Browse Folders - Easy• vmstore:• vmstores:

• cd vmstore:• dir (get-childitem)• dir –recurse | Select Name, ItemType

P. 28 of PowerCLI Admin Guide

@josh_atwell - @rtpsug

Page 15: PowerCLI for the PowerShell Inclined

Wider Management• VMware Update Manager• vCloud Director• View• AutoDeploy• Distributed Virtual Switch

@josh_atwell - @rtpsug

Page 16: PowerCLI for the PowerShell Inclined

Update Manager (VUM)

@josh_atwell - @rtpsug

NOTE: VUM Snap-in is version specific. V5 snap-in does not manage vSphere 4 Update Manager

• Locate Commands Quickly– Get-VICommand *patch*– Get-VICommand *baseline*– Get-VICommand –PSSnapin VMware.VumAutomation

Page 17: PowerCLI for the PowerShell Inclined

Project Onyx

@josh_atwell - @rtpsug

Now supporting vSphere 5.5!!

Page 18: PowerCLI for the PowerShell Inclined

PowerCLI Community

Get-PowerCLICommunity

http://www.vbrownbag.com/http://www.virtu-al.net/http://www.lucd.info/http://geekafterfive.com/http://vnugglets.com/ (Get-View)

@josh_atwell - @rtpsug

Page 19: PowerCLI for the PowerShell Inclined

Published Resources

@josh_atwell - @rtpsug

VMware vSphere PowerCLI Reference Alan Renouf, Luc Dekens, Glenn Sizemore, Jonathan Medd, Arnim van Lieshout

Managing VMware Infrastructure with Windows PowerShell Hal Rottenberg

VMware vSphere PowerCLI Hal Rottenberg PluralSight

Page 20: PowerCLI for the PowerShell Inclined

Published Resources

@josh_atwell - @rtpsug

Mastering vSphere 5.5 Scott Lowe, Nick Marshall, Forbes Guthrie, Matt Liebowitz, Josh Atwell

Learning PowerCLI Robert van den Nieuwendijk