Mastering PowerCLI
eBook - ePub

Mastering PowerCLI

  1. 430 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering PowerCLI

About this book

Master PowerCLI to automate all aspects of VMware environments

About This Book

  • Leverage PowerCLI to perform administration tasks in a more effective and efficient way
  • Escape from daily tedious and repetitive tasks by unleashing the full potential of your creative side through scripting
  • Master the intricate workings of PowerShell and PowerCLI through easy and real-life examples

Who This Book Is For

If you are a system administrator with working knowledge of PowerShell and PowerCLI who wants to perform quick and easy scripting but at the same time achieve complex results and write production grade scripts, then this book is for you.

What You Will Learn

  • Use GitHub for collaboration and Pester to automate unit tests
  • Write advanced reusable functions and dynamic variables and learn about error handling in PowerShell
  • Automate ESXi host installation using Auto-Deploy, host profile, and host image
  • Implement security best practices in a vSphere data center
  • Manage SRM, vCloud Air, and vRealize Operations environments
  • Access and utilize vSphere APIs to manage advanced aspects of vSphere and work with.NET view objects
  • Utilize REST APIs to manage vRealize Automation environments
  • Create a Windows GUI through the use of PowerShell and Sapien PrimalForms CE

In Detail

Have you ever wished that every morning you could automatically get a report with all the relevant information about your datacenter in exactly the same format you want? Or whether you could automate that boring, exhausting task? What if some crucial task needs to be performed on a regular basis without any error? PowerCLI scripts do all that and much more for VMware environments. It is built on top of the popular Windows PowerShell, with which you can automate server tasks and reduce manual input, allowing you to focus on more important tasks.

This book will help you to achieve your goals by starting with a short refresher on PowerShell and PowerCLI and then covering the nuances of advanced functions and reusable scripts. Next you will learn how to build a vSphere-powered virtualized datacenter using PowerCLI while managing different aspects of the environment including automated installation, network, and storage. You will then manage different logical constructs of vSphere environment and different aspects of a virtual machine.

Later, you will implement the best practices for a security implementation in vSphere Environment through PowerCLI before discovering how to manage other VMware environments such as SRM, vCloud Director and vCloud Air through PowerCLI. You will also learn to manage vSphere environments using advanced properties by accessing vSphere API and REST APIs through PowerCLI.

Finally, you will build a Windows GUI application using PowerShell followed by a couple of sample scripts for reporting and managing vSphere environments with detailed explanations of the scripts. By the end of the book, you will have the required in-depth knowledge to master the art of PowerCLI scripting.

Style and approach

In this book, every topic is explained in a very easy-to-follow fashion with real-life, simple examples so that you get an idea of not only the topic but also the context in which it should be used or where it can be best utilized.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Mastering PowerCLI


Table of Contents

Mastering PowerCLI
Credits
Foreword
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Instant updates on new Packt books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. PowerShell and PowerCLI Refresher
The essence of PowerShell and PowerCLI
The history of scripting
PowerShell
PowerCLI
The vSphere PowerCLI package
The vCloud PowerCLI package
Implementing programming constructs in PowerShell
Conditional logic
Conditional logic using loops
The difference between Foreach and Foreach-object
Automation through PowerShell scripts
Running and scheduling scripts
Using version control with GitHub
The fork & pull model
The shared repository model
Branch
Testing your scripts using Pester
Connecting to a vCenter and other VMware environments using PowerCLI cmdlets
Summary
2. Reusable Advanced Functions and Scripts
Specifying function attributes
Specifying parameter attributes
Using parameter validation attributes
Dynamic parameters
Switch parameters
PowerShell help files
Creating comment-based help
Error handling in PowerShell
Summary
3. Deploying vSphere Hosts
Image Builder with PowerCLI
Using host profiles
Configuring Auto Deploy for ESXi hosts
Adding hosts to a vCenter server
Summary
4. Managing Networks
Managing vSphere standard switches
Managing networking for ESXi
Managing vSphere distributed switches
Managing port groups
Creating private VLANs
Configuring vSphere network I/O control
Configuring Netflow
Working with ports
Configuring traffic shaping
Configuring port blocking
Configuring the security policy
Configuring the teaming policy
Summary
5. Managing Storage
Managing datastores
Configuring Fibre Channel storage
Configuring iSCSI storage
Configuring NFS storage
Configuring virtual SAN
Using datastore clusters
Using Raw Device Mapping
Managing storage using storage policy-based management
Cmdlets related to policy rules
Cmdlets related to storage policy
Cmdlets related to Spbm capabilities and compatible storage
Cmdlets related to policy application
Cmdlets related to policy backup and migration
Applying VMFS resignaturing
Configuring vFLASH using PowerCLI Extensions
Summary
6. Managing Clusters and Other Constructs
Configuring vCenter logical constructs
Folder
Datacenter
Cluster
Configuring the Enhanced vMotion Compatibility mode
Configuring High Availability
Using Dynamic Resource Scheduling
Using the DRS affinity and anti-affinity rules
Managing resource pools
Managing alarms
Summary
7. Managing Virtual Machines
Creating virtual machines
Modifying virtual machines
Hard disks
Network adapters and USB devices
Passthrough devices
Snapshots
Resource configuration and policies
Managing VMware tools in a VM
Managing templates
Managing OS customization specifications
Managing the guest OS
Managing vApps
Summary
8. Managing vSphere Security, SRM, vCloud Air, and vROps
The vSphere Security Hardening Guide
Managing vSphere Update Manager
Configuring a firewall and services in an ESXi host
Managing host profiles
Managing vCenter Site Recovery Manager
Managing vCloud Air
Managing vRealize Operations Manager
Summary
9. Managing the vSphere API
Using the Get-View cmdlet to return .NET View objects
Using the ExtensionData property to return .NET View objects
Using the vSphere API
Creating a vSphere scheduled task
Configuring Distributed Power Management
Configuring Fault Tolerance
Managing Content Libraries
Managing SRM advanced configurations
Generating PowerCLI code using Onyx
PowerActions for vSphere Web Client
Summary
10. Using REST APIs
Introducing REST APIs
Introducing JSON
Syntax rules
Values
The Invoke-RestMethod cmdlet
vRealize Automation REST APIs
Authenticating and getting a vRA token
Managing tenants
Creating a tenant
Listing identity stores for a tenant
Linking an identity store to a tenant
Managing machines
Listing shared and private catalog items
Managing approvals
Managing provisioned resources
Managing network profiles
Summary
11. Creating Windows GUI
Different ways to create a Windows GUI
Building a GUI using Windows Forms
Creating a button
Creating a TextBox
Creating ListBox
Creating CheckBox
Using SAPIEN PowerShell Studio
Building GUI using WPF
Summary
12. Best Practices and Sample Scripts
Best practices
Security Hardening Script
Capacity check report
Parameter descriptions
Using a proper editor
Sublime Text
ISESteroids
Summary
Index

Mastering PowerCLI

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure t...

Table of contents

  1. Mastering PowerCLI

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Mastering PowerCLI by Sajal Debnath in PDF and/or ePUB format, as well as other popular books in Computer Science & Virtualisation. We have over one million books available in our catalogue for you to explore.