powercli for the powershell inclined

Post on 07-Nov-2014

651 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

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.

TRANSCRIPT

PowerCLI for the PowerShell Inclined

Josh Atwellvtesseract.com

#vBrownBag Podcast@Josh_Atwell#RTPSUG / @RTPSUG

@josh_atwell - @rtpsug

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

@josh_atwell - @rtpsug

What is PowerCLI

www.vmware.com/go/powercli

Windows PowerShell for VMware Virtual Infrastructure and components

PowerCLI Admin Guide

@josh_atwell - @rtpsug

PowerCLI Capabilities

@josh_atwell - @rtpsug

First CommandsGet-PowerCLIConfiguration

Set-PowerCLIConfiguration –DefaultVIServerMode ‘multiple’

Get-PowerCLIVersion

@josh_atwell - @rtpsug

Connecting

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

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

$DefaultVIServer

@josh_atwell - @rtpsug

Get-View• Returns the vSphere .Net view objects

• Filters!

• Methods

• Check out vNugglets.com@josh_atwell - @rtpsug

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

@josh_atwell - @rtpsug

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

.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

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

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

Browse Folders - Easy• vmstore:• vmstores:

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

P. 28 of PowerCLI Admin Guide

@josh_atwell - @rtpsug

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

@josh_atwell - @rtpsug

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

Project Onyx

@josh_atwell - @rtpsug

Now supporting vSphere 5.5!!

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

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

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

top related