Command-Line Interfaces First Published On: Last Updated On:

Similar documents
DCLI User's Guide. Data Center Command-Line Interface 2.9.1

DCLI User's Guide. Data Center Command-Line Interface 2.7.0

DCLI User's Guide. Modified on 20 SEP 2018 Data Center Command-Line Interface

DCLI User's Guide. Data Center Command-Line Interface

vsphere APIs and SDKs First Published On: Last Updated On:

Disclaimer This presentation may contain product features that are currently under development. This overview of new technology represents no commitme

Vmware Vsphere Esx And Vcenter Server Documentation Center

Disclaimer This presentation may contain product features that are currently under development. This overview of new technology represents no commitme

Getting Started with vsphere Command-Line Interfaces

VMware vcenter Server Appliance Management Programming Guide. Modified on 28 MAY 2018 vcenter Server 6.7 VMware ESXi 6.7

vcenter Server Installation and Setup Modified on 11 MAY 2018 VMware vsphere 6.7 vcenter Server 6.7

Using VMware vrealize Orchestrator Plug-Ins. vrealize Orchestrator 6.0

Table of Contents HOL-1710-SDC-5

VMware vsphere 5.0 Evaluation Guide

Using VMware vrealize Orchestrator Plug-Ins. vrealize Orchestrator 7.1

vsphere Installation and Setup Update 2 Modified on 10 JULY 2018 VMware vsphere 6.5 VMware ESXi 6.5 vcenter Server 6.5

Using VMware vrealize Orchestrator Plug-Ins. 12 April 2018 vrealize Automation 7.4 vrealize Orchestrator 7.4

Using VMware vrealize Orchestrator Plug-Ins

Introduction to Virtualization

vsphere Command-Line Interface Concepts and Examples ESXi 6.5 vcenter Server 6.5

Getting Started with vsphere Command-Line Interfaces ESXi 5.1 vcenter Server 5.1

vsphere Command-Line Interface Concepts and Examples ESXi 6.5 vcenter Server 6.5

Purpose. Target Audience. Installation Overview. Install SDK Prerequisites. Nagios XI. Monitoring VMware With Nagios XI

Using the Horizon vcenter Orchestrator Plug-In. VMware Horizon 6 6.0

vsphere Upgrade Update 1 Modified on 4 OCT 2017 VMware vsphere 6.5 VMware ESXi 6.5 vcenter Server 6.5

Advanced Service Design. vrealize Automation 6.2

Front Office and VMware. Automating server provisioning from your Service Catalog

Administering VMware vsphere and vcenter 5

vsphere Command-Line Interface Concepts and Examples 17 APR 2018 ESXi 6.7 vcenter Server 6.7

vsphere PowerCLI Installation Guide VMware vsphere PowerCLI 4.1 Update 1 EN

VMware PowerCLI User's Guide. VMware PowerCLI 6.5.4

Developing and Deploying vsphere Solutions, vservices, and ESX Agents. 17 APR 2018 vsphere Web Services SDK 6.7 vcenter Server 6.7 VMware ESXi 6.

Horizon Console Administration. 13 DEC 2018 VMware Horizon 7 7.7

vcenter Server Installation and Setup Update 1 Modified on 30 OCT 2018 VMware vsphere 6.7 vcenter Server 6.7

Developing and Deploying vsphere Solutions, vservices, and ESX Agents

Dell EMC vsan Ready Nodes for VDI

Using the VMware vrealize Orchestrator Client

What s New in VMware vsphere 5.1 Platform

Using the VMware vcenter Orchestrator Client. vrealize Orchestrator 5.5.1

Developing and Deploying vsphere Solutions, vservices, and ESX Agents

VMware vsphere PowerCLI Reference

VMware vsphere 6.5/6.0 Ultimate Bootcamp

Using the Horizon vrealize Orchestrator Plug-In

vsphere Replication for Disaster Recovery to Cloud

VMware Skyline Collector Installation and Configuration Guide. VMware Skyline 1.4

Dell EMC Ready Architectures for VDI

VMware vsphere with ESX 6 and vcenter 6

Using the vrealize Orchestrator Operations Client. vrealize Orchestrator 7.5

Developing and Deploying vsphere Solutions, vservices, and ESX Agents

vcloud Usage Meter 3.5 User's Guide vcloud Usage Meter 3.5

Vmware Esx 3.0 Manual Mac Address Range

Upgrade Guide. vcloud Availability for vcloud Director 2.0

Table of Contents 1.1. Install, Deploy, Maintain Infrastructure Installation Download. Deploy the Appliance

Installing and Configuring vcloud Connector

vsphere Upgrade Update 2 Modified on 4 OCT 2017 VMware vsphere 6.0 VMware ESXi 6.0 vcenter Server 6.0

VMware vrealize Code Stream Reference Architecture. 16 MAY 2017 vrealize Code Stream 2.3

vsphere Replication for Disaster Recovery to Cloud vsphere Replication 6.5

efolder BDR for Veeam VMware Continuity Cloud Guide

VMware vrealize Code Stream Reference Architecture. 12 APRIL 2018 vrealize Code Stream 2.4

Table of Contents HOL-SDC-1422

IaaS Integration for Multi- Machine Services. vrealize Automation 6.2

PowerShell-Module Documentation. Release docs

VMware PowerCLI User's Guide

Test-King.VMCE_V8.40Q.A

Virtual Volumes FAQs First Published On: Last Updated On:

VMware Horizon View 5.2 Reviewer s Guide REVIEWER S GUIDE

vsphere Replication for Disaster Recovery to Cloud

vcloud Director Tenant Portal Guide 04 OCT 2018 vcloud Director 9.5

VMware Infrastructure Planner

VMWARE USER GUIDE PDF

NexentaStor VVOL

Platform Services Controller Administration. Update 1 Modified 03 NOV 2017 VMware vsphere 6.5 VMware ESXi 6.5 vcenter Server 6.5

INSTALLATION GUIDE. Virtual Appliance for Inspector and Reporter 9/20/2018 1:32 PM

VMWARE VREALIZE ORCHESTRATOR. Using the Plugin for FlashArray February 2017

IT Systems Integration

vsphere Replication for Disaster Recovery to Cloud vsphere Replication 8.1

Platform Services Controller Administration. Update 1 Modified on 11 DEC 2018 VMware vsphere 6.7 VMware ESXi 6.7 vcenter Server 6.

Data Protection Guide

Dell Storage Compellent Integration Tools for VMware

VMware Skyline Collector Installation and Configuration Guide. VMware Skyline Collector 2.0

Migrating vrealize Automation 6.2 to 7.1

EMC ViPR Controller. Create a VM and Provision and RDM with ViPR Controller and VMware vrealize Automation. Version 2.

vsphere SDK for Perl Installation Guide ESXi 5.0 Update 1 vcenter Server 5.0 Update 1

Table of Contents 1.1. Install, Deploy, Maintain Infrastructure Installation Download Installer. Deployment Prerequisites

Table of Contents DevOps Administrators

Table of Contents. Configure and Manage Logging in to the Management Portal Verify and Trust Certificates

vcloud Director Administrator's Guide

vsphere 6.0 Webcast Series

VMware Validated Design Backup and Restore Guide

Using VMware vrealize Orchestrator with VMware vcloud Availability for vcloud Director Version 1.0 April 2017

VMware vsphere 4. Architecture VMware Inc. All rights reserved

vsphere Web Client SDK Documentation VMware vsphere Web Client SDK VMware ESXi vcenter Server 6.5.1

VMware vrealize Operations for Horizon Installation

How to Deploy vcenter on the HX Data Platform

VMware vsphere Replication Security Guide

SnapCenter Software 4.0 Concepts Guide

Installation Guide Revision B. McAfee Cloud Workload Security 5.0.0

Virtual Appliance Installation Guide

vsphere Security Update 2 Modified on 22 JUN 2018 VMware vsphere 6.5 VMware ESXi 6.5 vcenter Server 6.5

Platform Services Controller Administration. Modified on 27 JUN 2018 VMware vsphere 6.7 VMware ESXi 6.7 vcenter Server 6.7

Transcription:

First Published On: 03-16-2017 Last Updated On: 07-31-2017 1

Table of Contents 1. PowerCLI 1.1.PowerCLI Overview 1.2.PowerCLI Blog 1.3.PowerCLI - VMTN Communities 1.4.PowerCLI Community Repository 1.5.PowerCLI Installation Walkthrough 2. vsphere CLI (vcli) 2.1.vSphere CLI - Overview 2.2.Datacenter CLI (DCLI) - Overview 2.3.DCLI - Interactive Mode 2.4.DCLI - Scripting Mode 2.5.DCLI - Getting Started Demonstration 2

1. PowerCLI VMware PowerCLI is a command-line and scripting tool built on Windows PowerShell which is used when managing and automating vsphere, vcloud, Horizon View, and more! 3

1.1 PowerCLI Overview VMware PowerCLI Overview VMware PowerCLI is a fantastic, free, command line and scripting tool that can be used to manage and automate many of VMware s products. If you ve worked with a VMware product, there s a good chance you ve already heard of it. PowerCLI is an extension of Windows PowerShell. PowerShell is an object-oriented programming language from Microsoft which is used for the automation of tasks as well as configuration management. Interacting with PowerShell is done through the use of cmdlets, which are formatted in a verb-noun pairing that is quite intuitive to the user. Additional cmdlets can be added to a PowerShell session by either snap-ins or modules. This is important to know because PowerShell can access and make use of the PowerCLI modules. While PowerShell has access to those modules, the user can then access over 500 different cmdlets It is an important command line interface (CLI) for a number of reasons that should be taken into consideration when selecting which VMware CLI should be used for the task at hand. First and foremost, PowerCLI has the widest coverage of VMware s CLIs. PowerCLI works with vsphere and many of its features including Auto Deploy, vsan, and Update Manager. PowerCLI also works with products outside of vsphere, such as Horizon View, Site Recovery Manager, vrealize Operations, and vcloud Air. PowerCLI also has an amazing user community! The VMware PowerCLI VMTN Communities boasts over 11,000 difference discussions where anyone from users to PowerCLI engineers can respond to questions, comments, or issues. Then, there is the PowerCLI Twitter handle which is closing in on 8,000 followers. There has also been a recent addition in the form of the VMware Code Slack team which has a PowerCLI channel that remains one of the most active channels with over 250 people joined. Lastly, PowerCLI has gone multi-platform. One of the largest complaints about PowerCLI was that it was limited to only being run on Windows based system. Well, PowerCLI has fully embraced Microsoft s open sourcing of.net and PowerShell and released a PowerCLI Core Fling! This fling allows Linux and Mac OS users to also run PowerCLI. 1.2 PowerCLI Blog PowerCLI is one of the few tools that features its own VMware blog! The PowerCLI blog contains over 300 different posts, which all focus on some form of technical content. Some of the posts are on new product announcements, others are on cmdlet deep dives and functional examples, and the list goes on. The blog can be found at the following URL: < http://blogs.vmware.com/powercli/ > 1.3 PowerCLI - VMTN Communities 4

The VMware VMTN Community for PowerCLI boasts over 11,000 difference discussions where anyone from users to PowerCLI engineers can respond to questions, comments, or issues. The community also features one of the highest rates of responses as well. It is extremely rare to see a discussion without at least one response. It is a great resource to not only receive answers to questions, but to browse as a learning tool. 1.4 PowerCLI Community Repository The VMware PowerCLI Community Repository < https://github.com/vmware/powercli-example- Scripts > is a central location where anyone can view and contribute their PowerCLI based resources. The repository is openly available from VMware s GitHub account. There are over 30 scripts, 15 modules, several PowerActions items, and other resources available today, with many more being added on a daily basis. The repository features a Principles of Operations < https://github.com/vmware/powercli-example- Scripts#principles-of-operations > document to help guide contributors along the process of using, creating, and updating resources which are contained within the repository. This community repository will also feature several community members as board members. As part of the board, they will be asked to help maintain the repository with tasks such as testing and providing feedback on all submitted resources, communicating with other board members in order to approve pull requests, and continuing to be good community advocates of PowerCLI and the community repository. 1.5 PowerCLI Installation Walkthrough VMware PowerCLI 6.5.1 Installation Walkthrough VMware PowerCLI 6.5.1 introduces a new installation method to users. This new method pulls directly from the PowerShell Gallery. This video will walk you through how to uninstall any previous versions of PowerCLI and then install PowerCLI 6.5.1. The video also separates out the process for systems with PowerShell 5.0 or PowerShell 3.0/4.0. Click to see topic media 5

2. vsphere CLI (vcli) vsphere CLI (vcli) is a package of several command sets whose goal is to manage and automate vsphere environments. 6

2.1 vsphere CLI - Overview vsphere CLI (vcli) is one of VMware s command line interfaces (CLI). However, vcli is actually a package of several command sets instead of being one itself. It is a great, free, tool whose goal is to manage and automate vsphere environments. It has evolved to be quite versatile over the releases. vcli can be installed on many Windows and Linux operating system (OS) offerings, provides both an interactive shell and the ability to script against it, and it can perform a wide range of tasks against vcenter Servers, ESXi hosts, VMs, and so forth. The vcli package contains several tools, CLIs, and SDKs (software development kits). vcli includes the Perl SDK, which allow users to run vicfg- based commands. vcli also includes two other CLIs, ESXCLI and Datacenter CLI (DCLI). ESXCLI is a way to manage ESXi hosts while connected to a vcenter Server or ESXi host. DCLI is a way to manage many parts of a vcenter Server environment. Lastly, there are a small set of commands which can be used to manage ESXi hosts. These commands are namely vmkfstools and resxtop. 2.2 Datacenter CLI (DCLI) - Overview An Overview of Datacenter CLI Datacenter Command-Line Interface (DCLI) is one of vsphere s newest CLIs. DCLI works exclusively with the vsphere Automation API (REST API for vsphere) to provide both an interactive and scriptable mode to monitor and manage all features made available to the REST based API. With the vsphere 6.5 release, DCLI has picked up a ton of new functionalities! DCLI can now interact with the vcenter Server Appliance (VCSA), perform VM tasks, receive environmental vsphere information, managing vsphere Tags, and work with the Content Library. This is definitely a great tool to have in the toolbox for anyone accessing a vsphere environment. Accessing DCLI DCLI is able to be installed on a multitude of Windows and Linux systems as part of the vsphere Command-Line Interface (vcli). DCLI is also automatically included within the vcenter Server Appliance (VCSA) as well as being included as part of the installation process for vcenter Server on Windows. Using DCLI There are two ways to use DCLI, either in an interactive shell or via scripting mode. Both methods have their benefits, so it comes down to either preference or what fits the use case at the time. Interactive Shell Scripting Mode Output Formatting DCLI also has the ability to change how the output from commands are handled. The formatter allows users to specify outputs of CSV, HTML, JSON, Simple, Table, or XML. Here s an example of using the formatter by showing a list of the hosts and then specifying the +formatter json parameter to receive the same output in JSON: 7

Credential Store One of the other big capabilities of DCLI is storing credentials with the Credential Store. This streamlines the process of connecting to the same vcenter repeatedly, and even more so when working in scripting mode. The first time a user connects to a vcenter server, they will be prompted to store the credentials to the credstore. After that initial save, the credstore will be referenced with each connection to that server. If needed, credentials can be specified at the command line to over-ride the values stored in the credstore. Users can also work with the credstore to either populate credentials with the +credstore-add +username user parameter, remove credentials with the +credstore-remove +user user +server servername.fqdn, and list what credentials already exist with the +credstore-list parameter. Here s an example output from using the +credstore-list parameter within an interactive mode session: Conclusion DCLI has, relatively, flown under the radar up until this point. Interactive mode allows even brand new users to easily access and run commands within moments of connecting and without knowin the name of the name spaces or reading documentation. Scripting mode lets users have those same great commands available outside of the interactive shell and utilize them in a standalone basis or within a scheduled task or cron job. These commands can easily be used with the formatter option to produce a variety of outputs and allow quick integration into other products. DCLI is a great and intuitive CLI that should be added to anyone s toolbox! For more information on getting started with DCLI, see the DCLI Reference. Originally Posted: VMware vsphere Blog - Getting Started with Datacenter CLI (DCLI) 8

2.3 DCLI - Interactive Mode DCLIs features an interactive shell with several great features. The most noteworthy features are tab complete, session history retention, and the ability to find a namespace just by starting it off with the first few characters. Accessing DCLI s Interactive Shell An example workflow to begin using DCLI s interactive shell: Start DCLI with the following options (Note: options start with a + in DCLI) +server -> The vcenter name/ip to connect to +skip-server-verification -> Instruct DCLI to ignore any certificate warnings +interactive -> Start the interactive mode Once in the interactive shell, users can start working immediately by either using tab to see the namespaces available or by starting to type in the name of the object they would like to begin viewing or working with. The below example below shows a tab complete example when working with VM objects: Another example below shows how to retrieve the VCSA s system version and then how the session history works: As seen in the above example, a user can recall a previously used command line just by typing in the first letter of that prior command. This eliminates the need for users to type in long command lines 9

while adding speed and consistency. The command history will persist through each of the user s sessions as well. 2.4 DCLI - Scripting Mode The scripting mode allows DCLI commands to be used within scripts. These scripts can then be turned into more extensive workflows and/or scheduled tasks. Accessing DCLI s Scripting Mode Calling DCLI commands through the scripting mode is fairly similar to the interactive mode, but a server has to be specified with each command. The full namespace should be referenced as well. Below is an example of retrieving the VCSA s system version followed by retrieving a list of VMs: Example Script Here is an example of a bash script to create 10 VMs on a given datastore, resource-pool and folder: #!/bin/bash COUNTER=0 while [ $COUNTER -lt 10 ]; do echo Creating LoopVM$COUNTER dcli com vmware vcenter vm create --name LoopVM$COUNTER --guest "SLES_12_64" -- resource-pool "resgroup-9" --folder "group-v7" --datastore "datastore-12" let COUNTER=COUNTER+1 done bold=$(tput bold) normal=$(tput sgr0) echo ${bold}--- VM List ---${normal} dcli com vmware vcenter vm list 2.5 DCLI - Getting Started Demonstration 10

Getting Started with vsphere's Datacenter Command-Line Interface Here s a demonstration video showing DCLI s interactive mode in action! The video details connecting to a VCSA, entering DCLI s interactive mode, displaying some general environmental information as well as pointing out some of the benefits when using interactive mode, and lastly it creates a VM and shows all the important information about that new VM. Click to see topic media 11