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

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Introducing JavaScript
CIS 240 Introduction to UNIX Instructor: Sue Sampson.
BROCADE ADX OPENSCRIPT March Derek Kang Solutions
Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
© 2010 Quest Software, Inc. ALL RIGHTS RESERVED Techstravaganza 2010 PowerShell 101 Dmitry Kagansky Solutions Architect - Quest Software (Public Sector)
True or false A variable of type char can hold the value 301. ( F )
James Boother Blog: INTRODUCTION TO POWERSHELL.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Linux+ Guide to Linux Certification, Second Edition
Practical Extraction & Report Language Picture taken from
Great people, great experience, great passion Administering SharePoint with Windows PowerShell Go Beyond the Management Shell with SharePoint and Windows.
Basic.  Powershell scripts are flat text files that end with “.ps1” (e.g. myscript.ps1)  Similar to other scripting languages, whatever you can do on.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
Microsoft ® Official Course Module 4 Automating Active Directory Domain Services Administration.
Shell Scripting Awk (part1) Awk Programming Language standard unix language that is geared for text processing and creating formatted reports but it.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
Introduction to Python
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
Week 9 PHP Cookies and Session Introduction to JavaScript.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Linux+ Guide to Linux Certification, Third Edition
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Introduction to Unix – CS 21
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
VApp Product Support Engineering Rev E VMware Confidential.
More Perl Data Types Scalar: it may be a number, a character string, or a reference to another data type. -the sigil $ is used to denote a scalar(or reference)
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Windows PowerShell. What is Windows PowerShell? A command-line interface (CLI) A new way of developing Windows and other products to be more manageable.
Linux+ Guide to Linux Certification, Second Edition
Advanced Task Engine Doing Cool Stuff with Cool stuff!
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Introduction to SQL Server Automation with Powershell by Chris Sommer.
Linux Administration Working with the BASH Shell.
Ravikanth C.
PHP using MySQL Database for Web Development (part II)
>> Fundamental Concepts in PHP
Loops BIS1523 – Lecture 10.
Getting Started with the Data ONTAP PowerShell Toolkit
Introduction to PowerShell
What is Bash Shell Scripting?
Getting started with Powershell for the DBA
PHP.
PowerShell Best Practices for SQL DBA’s
Cmdlets “Command-lets”
Linux Shell Script Programming
PowerShell Flow of Control Copyright © 2016 – Curt Hill.
Chapter 3: Selection Structures: Making Decisions
Chapter 3: Selection Structures: Making Decisions
Introduction to Bash Programming, part 3
Intro to Programming (in JavaScript)
Presentation transcript:

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

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

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

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

Getting Help Get-Help Get-Command 5

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

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

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

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

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

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

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

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

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

Function Example 15

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

Powershell ISE 17 Script Pane Output Pane Command Pane

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

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

VMware PowerCLI 20

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

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

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

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

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

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

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

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

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

VMware Onyx 30

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

vCloud Powershell 32

Why the Cloud? 33

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

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

Set-TheEnd Web: bluelock.com 36