VMware Cloud Community
moellerjot
Enthusiast
Enthusiast
Jump to solution

VMware.VimAutomation.Cloud.Views.User Modify / Lock / Enable User

Hi all, first try...

Is there a way to modify a vCD (9.7) User by using some call Like  UpdateUser@VMware.VimAutomation.Cloud.Views.User

Creation is fine:
$OrgED = (Get-Org 'MyOrgName').ExtensionData

$orgAdminUser = New-Object VMware.VimAutomation.Cloud.Views.User
$orgAdminUser.Name = $Name
$orgAdminUser.FullName = $FullName
$orgAdminUser.EmailAddress = $EmailAddress
$orgAdminUser.Password = $Pasword
$orgAdminUser.Telephone= $MyTel
$orgAdminUser.IsEnabled = $True
$orgAdminUser.IM = date

$user = $orgED.CreateUser($orgAdminUser)

Deleting works fine, but to hard: 

$user=get-ciuser -Org 'MyOrgName' myname 
$user.ExtensionData.Delete()

Searching for something like: 
$user.ExtensionData.IsLocked = $True
$user.ExtensionData.UpdateUser()

Any Idea?

Regards
moellerj 

 

Labels (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

A user account is locked after a certain number of invalid login attempts.

$User = Get-ciuser -name 'Admin' -Org 'org-test' | Get-ciview


Disable user:
$user.IsEnabled=$False
$user.UpdateServerData()

Enable user:

$user.IsEnabled=$True
$user.UpdateServerData()

Unlock user:
$user.Unlock()

View solution in original post

2 Replies
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

A user account is locked after a certain number of invalid login attempts.

$User = Get-ciuser -name 'Admin' -Org 'org-test' | Get-ciview


Disable user:
$user.IsEnabled=$False
$user.UpdateServerData()

Enable user:

$user.IsEnabled=$True
$user.UpdateServerData()

Unlock user:
$user.Unlock()

pderrick81
Contributor
Contributor
Jump to solution

Thanks @Macleud - this was really helpful after several hours of trying to find an easy way to bulk-change Org User Roles so I tried same method to modify User Role Name, Href and ID which ended up sparing me from "death by UI" - manually changing hundreds of Org Users Role from "A" to "B" etc... simply sharing to aid others that come across this post as I couldn't find anything else and your post provided the solution given further mods...

PS > $User = Get-ciuser -name 'Admin' -Org 'org-test' | Get-ciview

# Can see the Role name (and related Href + Id if doing same for those too...) in this example:

PS > $User.Role
Client : VMware.VimAutomation.Cloud.Views.CloudClient
Href : https://vcloud.com/api/admin/role/29235e7f5-3d13-37b5-82cd-a45512417142
Id : urn:vcloud:role:2945e7f4-2e15-33b5-82cd-a45302316143
Type : application/vnd.vmware.admin.role+xml
Name : A
AnyAttr :
VCloudExtension :

# New Role Name, Href, Id:

PS > $User.Role.Name="B"
PS > $User.Role.Id="urn:vcloud:role:ef59dc77-fa75-368c-943e-282c2e608e81"
PS > $User.Role.Href="https://vcloud.com/api/admin/role/ef59dc77-fa75-368c-943e-282c2e608e81"
PS > $User.UpdateServerData()

PS > $User = Get-ciuser -name 'Admin' -Org 'org-test' | Get-ciview

PS > $User.Role

Client : VMware.VimAutomation.Cloud.Views.CloudClient
Href : https://vcloud.com/api/admin/role/ef59dc77-fa75-368c-943e-282c2e608e81
Id : urn:vcloud:role:ef59dc77-fa75-368c-943e-282c2e608e81"
Type : application/vnd.vmware.admin.role+xml
Name : B
AnyAttr :
VCloudExtension :

# Displayed as expected, and UI refresh displayed the same... thanks again! 🙂

Reply
0 Kudos