VMware-vCD-Module

Create new Org, OrgUser, OrgVDC
This commit is contained in:
mycloudrevolution
2017-06-13 22:51:12 +02:00
parent 96a5ce3cee
commit e1bc6912fa
10 changed files with 830 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
#Requires -Version 4
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
Function New-MyOrgAdmin {
<#
.SYNOPSIS
Creates a new vCD Org Admin with Default Parameters
.DESCRIPTION
Creates a new vCD Org Admin with Default Parameters
Default Parameters are:
* User Role
.NOTES
File Name : New-MyOrgAdmin.ps1
Author : Markus Kraus
Version : 1.1
State : Ready
.LINK
https://mycloudrevolution.com/
.EXAMPLE
New-MyOrgAdmin -Name "OrgAdmin" -Pasword "Anfang!!" -FullName "Org Admin" -EmailAddress "OrgAdmin@TestOrg.local" -Org "TestOrg"
.PARAMETER Name
Name of the New Org Admin as String
.PARAMETER FullName
Full Name of the New Org Admin as String
.PARAMETER Password
Password of the New Org Admin as String
.PARAMETER EmailAddress
EmailAddress of the New Org Admin as String
.PARAMETER Enabled
Should the New Org be enabled after creation
Default:$false
.PARAMETER Org
Org where the new Org Admin should be created as string
#>
Param (
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Org Admin as String")]
[ValidateNotNullorEmpty()]
[String] $Name,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Password of the New Org Admin as String")]
[ValidateNotNullorEmpty()]
[String] $Pasword,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Name of the New Org Admin as String")]
[ValidateNotNullorEmpty()]
[String] $FullName,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="EmailAddress of the New Org Admin as String")]
[ValidateNotNullorEmpty()]
[String] $EmailAddress,
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Org Admin should be created as string")]
[ValidateNotNullorEmpty()]
[String] $Org,
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the New Org be enabled after creation")]
[ValidateNotNullorEmpty()]
[Switch]$Enabled
)
Process {
## Create Objects
$OrgED = (Get-Org $Org).ExtensionData
$orgAdminUser = New-Object VMware.VimAutomation.Cloud.Views.User
## Settings
$orgAdminUser.Name = $Name
$orgAdminUser.FullName = $FullName
$orgAdminUser.EmailAddress = $EmailAddress
$orgAdminUser.Password = $Pasword
$orgAdminUser.IsEnabled = $Enabled
$vcloud = $DefaultCIServers[0].ExtensionData
## Find Role
$orgAdminRole = $vcloud.RoleReferences.RoleReference | Where-Object {$_.Name -eq "Organization Administrator"}
$orgAdminUser.Role = $orgAdminRole
## Create User
$user = $orgED.CreateUser($orgAdminUser)
Get-CIUser -Org $Org -Name $Name | Format-Table -AutoSize
}
}