Book Image

PowerCLI Cookbook

By : Philip Brandon Sellers
Book Image

PowerCLI Cookbook

By: Philip Brandon Sellers

Overview of this book

Table of Contents (19 chapters)
PowerCLI Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a new user in an organization using Views


In this recipe, since PowerCLI does not yet have a New-CIUser cmdlet, you will write a function to handle this process. The function requires to have the correct rights to create organizational users, but it will allow you to create users from PowerCLI without having to switch back to the web console. The code and function are based on a blog post from Alan Renouf, a product manager who focuses on automation frameworks and CLI at VMware.

Getting ready

To begin this recipe, open PowerShell ISE and set up a VMware PowerCLI environment by adding the PSSnapIn cmdlet, VMware.VimAutomation.Core.

How to do it…

In order to create a new user in an organization using Views, perform the following steps:

  1. In PowerShell ISE, set up a basic function definition for New-CIUser:

    Function New-CIUser {
    
  2. Next, add your synopsis and help text to the function:

    <#
    .SYNOPSIS
      Creates a new user in a vCloud installation
    .DESCRIPTION
      Creates a new user account in...