Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with VMware PowerCLI Jake Robinson, Systems Engineer Bluelock 1.

Similar presentations


Presentation on theme: "Getting Started with VMware PowerCLI Jake Robinson, Systems Engineer Bluelock 1."— Presentation transcript:

1 Getting Started with VMware PowerCLI Jake Robinson, Systems Engineer Bluelock 1

2 Welcome 2 Intro Microsoft Powershell Break! VMware PowerCLI vCloud Powershell Extra Question/Lab Time

3 What is Powershell? Automation Engine Scripting Language Object, not text processing.NET libraries Extensible framework Integrated help system ISE 3

4 The Powershell cmdlet Native, compiled command Always follow verb-noun format Get-Beer Snap-ins Aliases 4

5 Getting Help Get-Help Get-Command 5

6 Piping and the Pipeline The “pipe” Passes output(object) to another command Get-Process notepad | Stop-Process Get-Process | Where-Object {$_.name –eq notepad} | Stop-Process Woah, what the heck is “$_” Special variable for “This.” Basically, whatever object is currently in the pipeline. 6

7 Variables They store stuff. (objects) They start with a $. $jake = “nerd” 7

8 Some important Variables 8 Variable NameDescription $_ The current pipeline object; used in script blocks, filters, the process clause of functions, where-object, foreach-object and switch $^ contains the first token of the last line input into the shell $$ contains the last token of last line input into the shell $? Contains the success/fail status of the last statement $Args Used in creating functions that require parameters $Env:PathEnvironmental Path to files. $Error If an error occurred, the object is saved in the $error PowerShell variable $foreachRefers to the enumerator in a foreach loop. $HOMEThe user's home directory; set to %HOMEDRIVE%\%HOMEPATH% $InputInput piped to a function or code block $MatchA hash table consisting of items found by the –match operator. $MyInvocationInformation about the currently script or command-line $HostInformation about the currently executing host $LastExitCodeThe exit code of the last native application to run $trueBoolean TRUE $falseBoolean FALSE $nullA null object $OFS Output Field Separator, used when converting an array to a string. By default, this is set to the space character. $ShellID The identifier for the shell. This value is used by the shell to determine the ExecutionPolicy and what profiles are run at startup. $StackTrace contains detailed stack trace information about the last error

9 Arithmetic and Assignment Operators 9 OperatorDefinition +Adds two things together. (numbers, strings, etc) -Subtract (also can make a number negative!) *Multiply /Divide %Divides and returns the remainder OperatorDefinition =Assigns a value +=Increases value by specified amount -=Decreases value by specified amount *=Multiplies value by specified amount /=Divides value by specified amount %=Divides value by specified amount (remainder) ++Increment by 1. --Decrement by 1

10 Comparison Operators 10 OperatorDefinition -ltLess than -leLess than or equal to -gtGreater than -geGreater than or equal to -eqEqual to -neNot Equal to -contains Determine elements in a group. This always returns Boolean $True or $False. -notcontains Determine excluded elements in a group This always returns Boolean $True or $False. -likeLike - uses wildcards for pattern matching -notlikeNot Like - uses wildcards for pattern matching -match Match - uses regular expressions for pattern matching -notmatch Not Match - uses regular expressions for pattern matching

11 Filtering and Formatting Where-Object Only show me certain objects Get-Process | Where-Object {$_.WS –gt 10MB} Select-Object Only show me certain properties of an object Get-Process | select name, id 11

12 Filtering and Formatting Format-List Vertical view of properties Not fun to look at when you have more that one object Great for deep-diving into a single object Format-List * (displays all properties of an object) Format-Table Horizontal view of properties Not fun to look at when you have lots of properties Great for viewing a lot of objects and a few properties 12

13 Foreach-Object Do something to each object in our pipeline Get-Process | Foreach-Object {Write-host “Jake” $_.name} 13 Process Get-Process ForEach-Object Write-Host “Jake” $_.name

14 Functions Reusable code! Save functions in a.ps1 file Import functions by “dot-sourcing”. C:\scripts\myFunctions.ps1 14 dot space

15 Function Example 15

16 Powershell ISE “Integrated Scripting Environment” Ooh, colors… Panes Script pane Command pane Output pane 16

17 Powershell ISE 17 Script Pane Output Pane Command Pane

18 BREAK TIME! Get-Beer | where {$_.temperature –eq COLD} 18

19 Bluelock is Hiring! Want a Challenge? Passionate about virtualization? Systems Engineer Software Engineer Support Specialist (2 nd Shift) Engagement Manager Account Executive Accounting Specialist For more info: 19

20 VMware PowerCLI 20

21 What is PowerCLI? Powershell Snapin Over 250 Cmdlets! Strong Community Service Console Alternative 21

22 Adding the Snapin vs Running PowerCLI The PowerCLI icon generates aliases (eg Get-PowerCLIHelp ) A little slower startup, in my experience Adding the snapin to powershell Easy to add snapin Don’t rely on aliases Easier for task scheduling Add to Powershell profile 22

23 Add snapin and connect Add-PSSnapin vmware.vimautomation.core Demo… Let’s look at their Cmdlets… Get-Command –PSSnapin vmware* Connect-VIServer Demo… 23

24 Getting information Get-Datacenter Get-Cluster Get-Datastore Get-VirtualSwitch Get-ResourcePool Get-VM Get-Harddisk 24

25 Getting more detail Format-List * Get-View (Advanced) Returns the ENTIRE.NET object Including methods and properties! 25

26 Reporting There’s a Cmdlet for that… ConvertTo-HTML Export-CSV Out-File vCheck LOTS of fun information! 26

27 Making Changes Start/Stop/Reset VMs (hard) Shutdown/Restart VMGuest (Soft) VM settings The –WhatIf switch Create VMs The –RunAsync switch Delete VMs -DeletePermanently 27

28 Cool personal use cases The case of the Hex WWNs The case of the Broken Path The case of the Over-Powered Hosts 28

29 Your turn… vCenter Server:Sorry, lab not available. Username:labuser Password:Ilovepowercli 29 Connect-VIServer Browse around with some Get Cmdlets Create a new VM (use your first initial, last name as the VM) Power it up! Create a snapshot! Power it down, Delete the VM! Can you

30 VMware Onyx 30

31 Onyx It’s a vCenter Proxy Captures traffic, turns it into PowerShell Code Demo… 31 Onyx vSphere Client vCenter Code!

32 vCloud Powershell 32

33 Why the Cloud? 33

34 vCloud Powershell The inventory dilemma again! Can’t get the info from vCenter All the info was in vCloud Director The vCloud API RESTful Nothing existed for Powershell 34

35 vCloud Powershell Demo! Get-vCloudVM PowerOff-vCloudVM PowerOn-vCloudVM Get-vCloudConsole 35

36 Set-TheEnd Web: bluelock.com 36


Download ppt "Getting Started with VMware PowerCLI Jake Robinson, Systems Engineer Bluelock 1."

Similar presentations


Ads by Google