From f3c549a8671644e1fa513076dba998ba994f0007 Mon Sep 17 00:00:00 2001 From: William Lam Date: Fri, 28 Feb 2020 10:34:01 -0800 Subject: [PATCH] Consolidated VCSA functions into VCSA Module --- .../VCSA.psm1} | 29 +++++++++++++++++++ .../VCSAIdentitySource.psm1 | 28 ------------------ 2 files changed, 29 insertions(+), 28 deletions(-) rename Modules/{VCSAPasswordPolicy/VCSAPasswordPolicy.psm1 => VCSA/VCSA.psm1} (64%) delete mode 100644 Modules/VCSAIdentitySource/VCSAIdentitySource.psm1 diff --git a/Modules/VCSAPasswordPolicy/VCSAPasswordPolicy.psm1 b/Modules/VCSA/VCSA.psm1 similarity index 64% rename from Modules/VCSAPasswordPolicy/VCSAPasswordPolicy.psm1 rename to Modules/VCSA/VCSA.psm1 index 55963ca..a0bac0e 100644 --- a/Modules/VCSAPasswordPolicy/VCSAPasswordPolicy.psm1 +++ b/Modules/VCSA/VCSA.psm1 @@ -36,4 +36,33 @@ Function Get-VCSAPasswordPolicy { } else { Write-Host "`nUnable to find VCSA named $VCSAName" } +} + +Function Get-VCSAIdentitySource { +<# + .DESCRIPTION Retrieves vCenter Server Appliance Identity Source Configuration + .NOTES Author: William Lam + .PARAMETER VCSAName + Inventory name of the VCSA VM + .PARAMETER VCSARootPassword + Root password for VCSA VM + .EXAMPLE + Get-VCSAIdentitySource -VCSAName "MGMT-VCSA-01" -VCSARootPassword "VMware1!" +#> + Param ( + [Parameter(Mandatory=$true)][String]$VCSAName, + [Parameter(Mandatory=$true)][String]$VCSARootPassword + ) + + $vm = Get-Vm -Name $VCSAName + + if($vm) { + $identitySources = Invoke-VMScript -ScriptText "/opt/vmware/bin/sso-config.sh -get_identity_sources 2> /dev/null | sed -ne '/^*/,$ p'" -vm $vm -GuestUser "root" -GuestPassword $VCSARootPassword + + Write-Host -ForegroundColor green "`nIdentity Sources: " + $identitySources + + } else { + Write-Host "`nUnable to find VCSA named $VCSAName" + } } \ No newline at end of file diff --git a/Modules/VCSAIdentitySource/VCSAIdentitySource.psm1 b/Modules/VCSAIdentitySource/VCSAIdentitySource.psm1 deleted file mode 100644 index 596cab1..0000000 --- a/Modules/VCSAIdentitySource/VCSAIdentitySource.psm1 +++ /dev/null @@ -1,28 +0,0 @@ -Function Get-VCSAIdentitySource { -<# - .DESCRIPTION Retrieves vCenter Server Appliance Identity Source Configuration - .NOTES Author: William Lam - .PARAMETER VCSAName - Inventory name of the VCSA VM - .PARAMETER VCSARootPassword - Root password for VCSA VM - .EXAMPLE - Get-VCSAIdentitySource -VCSAName "MGMT-VCSA-01" -VCSARootPassword "VMware1!" -#> - Param ( - [Parameter(Mandatory=$true)][String]$VCSAName, - [Parameter(Mandatory=$true)][String]$VCSARootPassword - ) - - $vm = Get-Vm -Name $VCSAName - - if($vm) { - $identitySources = Invoke-VMScript -ScriptText "/opt/vmware/bin/sso-config.sh -get_identity_sources 2> /dev/null | sed -ne '/^*/,$ p'" -vm $vm -GuestUser "root" -GuestPassword $VCSARootPassword - - Write-Host -ForegroundColor green "`nIdentity Sources: " - $identitySources - - } else { - Write-Host "`nUnable to find VCSA named $VCSAName" - } -} \ No newline at end of file