@@ -546,4 +546,171 @@ Function Get-VAMIBackupSize {
546
546
547
547
Write-Host " Estimated Backup Size: $estimateBackupSize MB"
548
548
Write-Host $backupPartSizes
549
+ }
550
+
551
+ Function Get-VAMIUser {
552
+ <#
553
+ . NOTES
554
+ ===========================================================================
555
+ Created by: William Lam
556
+ Organization: VMware
557
+ Blog: www.virtuallyghetto.com
558
+ Twitter: @lamw
559
+ ===========================================================================
560
+ . SYNOPSIS
561
+ This function retrieves VAMI local users using VAMI interface (5480)
562
+ for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
563
+ . DESCRIPTION
564
+ Function to retrieve VAMI local users
565
+ . EXAMPLE
566
+ Connect-CisServer -Server 192.168.1.51 -User [email protected] -Password VMware1!
567
+ Get-VAMIUser
568
+ #>
569
+ param (
570
+ [Parameter (
571
+ Mandatory = $false ,
572
+ ValueFromPipeline = $true ,
573
+ ValueFromPipelineByPropertyName = $true )
574
+ ]
575
+ [String ]$Name
576
+ )
577
+
578
+ $userAPI = Get-CisService ' com.vmware.appliance.techpreview.localaccounts.user'
579
+
580
+ $userResults = @ ()
581
+
582
+ if ($Name -ne " " ) {
583
+ try {
584
+ $user = $userAPI.get ($name )
585
+
586
+ $userString = [pscustomobject ] @ {
587
+ User = $user.username
588
+ Name = $user.fullname
589
+ Email = $user.email
590
+ Status = $user.status
591
+ PasswordStatus = $user.passwordstatus
592
+ Role = $user.role
593
+ }
594
+ $userResults += $userString
595
+ } catch {
596
+ Write-Error $Error [0 ].exception.Message
597
+ }
598
+ } else {
599
+ $users = $userAPI.list ()
600
+
601
+ foreach ($user in $users ) {
602
+ $userString = [pscustomobject ] @ {
603
+ User = $user.username
604
+ Name = $user.fullname
605
+ Email = $user.email
606
+ Status = $user.status
607
+ PasswordStatus = $user.passwordstatus
608
+ Role = $user.role
609
+ }
610
+ $userResults += $userString
611
+ }
612
+ }
613
+ $userResults
614
+ }
615
+
616
+ Function New-VAMIUser {
617
+ <#
618
+ . NOTES
619
+ ===========================================================================
620
+ Created by: William Lam
621
+ Organization: VMware
622
+ Blog: www.virtuallyghetto.com
623
+ Twitter: @lamw
624
+ ===========================================================================
625
+ . SYNOPSIS
626
+ This function to create new VAMI local user using VAMI interface (5480)
627
+ for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
628
+ . DESCRIPTION
629
+ Function to create a new VAMI local user
630
+ . EXAMPLE
631
+ Connect-CisServer -Server 192.168.1.51 -User [email protected] -Password VMware1!
632
+ New-VAMIUser -name lamw -fullname "William Lam" -role "operator" -email "[email protected] " -password "VMware1!"
633
+ #>
634
+ param (
635
+ [Parameter (
636
+ Mandatory = $true )
637
+ ]
638
+ [String ]$name ,
639
+ [Parameter (
640
+ Mandatory = $true )
641
+ ]
642
+ [String ]$fullname ,
643
+ [Parameter (
644
+ Mandatory = $true )
645
+ ]
646
+ [ValidateSet (" admin" , " operator" , " superAdmin" )][String ]$role ,
647
+ [Parameter (
648
+ Mandatory = $false )
649
+ ]
650
+ [String ]$email = " " ,
651
+ [Parameter (
652
+ Mandatory = $true )
653
+ ]
654
+ [String ]$password
655
+ )
656
+
657
+ $userAPI = Get-CisService ' com.vmware.appliance.techpreview.localaccounts.user'
658
+ $createSpec = $userAPI.Help.add.config.CreateExample ()
659
+
660
+ $createSpec.username = $name
661
+ $createSpec.fullname = $fullname
662
+ $createSpec.role = $role
663
+ $createSpec.email = $email
664
+ $createSpec.password = [VMware.VimAutomation.Cis.Core.Types.V1.Secret ]$password
665
+
666
+ try {
667
+ Write-Host " Creating new user $name ..."
668
+ $userAPI.add ($createSpec )
669
+ } catch {
670
+ Write-Error $Error [0 ].exception.Message
671
+ }
672
+ }
673
+
674
+ Function Remove-VAMIUser {
675
+ <#
676
+ . NOTES
677
+ ===========================================================================
678
+ Created by: William Lam
679
+ Organization: VMware
680
+ Blog: www.virtuallyghetto.com
681
+ Twitter: @lamw
682
+ ===========================================================================
683
+ . SYNOPSIS
684
+ This function to remove VAMI local user using VAMI interface (5480)
685
+ for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA.
686
+ . DESCRIPTION
687
+ Function to remove VAMI local user
688
+ . EXAMPLE
689
+ Connect-CisServer -Server 192.168.1.51 -User [email protected] -Password VMware1!
690
+ Get-VAMIAccess
691
+ #>
692
+ param (
693
+ [Parameter (
694
+ Mandatory = $true )
695
+ ]
696
+ [String ]$name ,
697
+ [Parameter (
698
+ Mandatory = $false )
699
+ ]
700
+ [boolean ]$confirm = $false
701
+ )
702
+
703
+ if (! $confirm ) {
704
+ $answer = Read-Host - Prompt " Do you want to delete user $name (Y or N)"
705
+ if ($answer -eq " Y" -or $answer -eq " y" ) {
706
+ $userAPI = Get-CisService ' com.vmware.appliance.techpreview.localaccounts.user'
707
+
708
+ try {
709
+ Write-Host " Deleting user $name ..."
710
+ $userAPI.delete ($name )
711
+ } catch {
712
+ Write-Error $Error [0 ].exception.Message
713
+ }
714
+ }
715
+ }
549
716
}
0 commit comments