VMware Cloud Community
rwigand
Contributor
Contributor

new-ciuser?

hi!

just created my first Cloud Organisation with vSphere PowerCLI 5.1 with

new-org -name "bla" -fullname "blubb"

IfI do this on the Web Frontend, the next page will ask me for an admin user for that Organisation. I found the

get-ciuser -org "bla"

but since there is no user defined so far the output is empty - as expected. Unfortunally I did not found a cmdlet like new-ciuser, so how to do that?

Sorry if this is a silly question but I already started with the PowerCLI and still looking for more examples. I found the book from Alan Renouf und Luc Dekens but I am not sure if it covers the vCloud cmdlets - doesn't seem so. Any other suggestions?

Thanks for your help!

Ralf

Tags (1)
0 Kudos
4 Replies
LucD
Leadership
Leadership

Moved to the vCD PowerCLI community


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jake_robinson_b
Hot Shot
Hot Shot

Hi Ralf,

Creating new users are a bit more complicated, but not impossible. There is not a New-CIUser cmdlet *yet*, but I'll show you the way you can do it now!

We'll need 3 things: A username, a password, and a role.

To get the role we want to assign the user, we'll need to use Search-Cloud:

Search-Cloud -QueryType Role | select Name

This will give us a list of roles. Pick a role name. As an example, I want to add an Org admin, so I am going to run this:

$role = Search-Cloud -QueryType Role -Name "Organization Administrator" | Get-CIView

The previous line queried for the role, retrieved the role object using Get-CIView and assigned it to the $role variable.

Congrats, that was the hardest part... on to the good stuff!

We need to do two things next... Get our Org object, and create a new user object:

$org = Get-Org

$user = New-Object VMware.VimAutomation.Cloud.Views.User

Now we assign the fun stuff to our user object (name, password, role)!

$user.Name = "JakeRobinson"

$user.Password = "myPassword"

$user.Role = $role.href

$user.IsEnabled = $true

and finally, we push the user object to our Org:

$org.ExtensionData.createUser($user)

So that's it! Probably 10 lines of code and we have a new user. The secret is really in the .extensiondata of the objects like $org.

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
0 Kudos
jtokach
Contributor
Contributor

I'm sorry to hijack this thread, but it's directly related. I want to create vCloud org groups. Straight forward with simple mods to the above code. But I also need to link LDAP (Active Directory) groups. I can't figure that out...

0 Kudos
jake_robinson_b
Hot Shot
Hot Shot

Pretty much this: :smileygrin:

$org = get-org "Some Org"

$group = New-Object VMware.VimAutomation.Cloud.Views.Group

# Customize $group here

$org.ExtensionData.CreateGroup($group)

Jake Robinson VCP, vExpert - geekafterfive.com - Twitter: @jakerobinson
0 Kudos