From 44ec63f68fe597e00c916b4e0950dbce4f4bfa43 Mon Sep 17 00:00:00 2001 From: Gary Blake <31245616+GaryJBlake@users.noreply.github.com> Date: Thu, 30 Nov 2023 08:32:22 +0000 Subject: [PATCH] chore: code formatting for ad and cloud foundation functions (#418) - Applied code formatting standards to Active Directory and Cloud Foundation functions. - Fixed `Get-WSAServerDetails` cmdlet where incorrect initial check was looking for VMware Aria Automation not VMware Aria Suite Lifecycle. - Enhanced `Get-WSAServerDetails` cmdlet to include credentials and node code for the VCF-Aware Workspace ONE Access instance. Signed-off-by: Gary Blake --- CHANGELOG.md | 2 + PowerValidatedSolutions.psd1 | 2 +- PowerValidatedSolutions.psm1 | 74 ++++++++++++++---------------------- 3 files changed, 31 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05bcb877..60bd9f47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Fixed `Undo-vCenterGlobalPermission` cmdlet where incorrect input variable is checked. - Fixed `Set-NsxtRole` cmdlet where missing input commands were missing from the example. - Fixed `Export-vROPSJsonSpec` cmdlet to not populate secondary NTP server address from the Planning and Preparation workbook. +- Fixed `Get-WSAServerDetails` cmdlet where incorrect initial check was looking for VMware Aria Automation not VMware Aria Suite Lifecycle. - Fixed `Add-vRLIAuthenticationWSA` cmdlet description and synopsis which was incorrect. - Added `Export-IamJsonSpec` cmdlet to generate a JSON specification file for Identify and Access Management. - Added `Invoke-IamDeployment` cmdlet to perform an end-to-end deployment of Identify and Access Management. @@ -42,6 +43,7 @@ - Enhanced `New-WSADeployment` cmdlet to check for the existence of a load balancer in VMware Aria Suite Lifecycle and if missing create it. - Enhanced `New-vROPSDeployment` cmdlet to check for the existence of the a load balancer in VMware Aria Suite Lifecycle and if missing create it. - Enhanced `New-vRADeployment` cmdlet to check for the existence of the a load balancer in VMware Aria Suite Lifecycle and if missing create it. +- Enhanced `Get-WSAServerDetails` cmdlet to include credentials and node code for the VCF-Aware Workspace ONE Access instance. ## v2.7.1 diff --git a/PowerValidatedSolutions.psd1 b/PowerValidatedSolutions.psd1 index 9563829f..7ea719ef 100644 --- a/PowerValidatedSolutions.psd1 +++ b/PowerValidatedSolutions.psd1 @@ -12,7 +12,7 @@ RootModule = 'PowerValidatedSolutions.psm1' # Version number of this module. - ModuleVersion = '2.8.0.1011' + ModuleVersion = '2.8.0.1012' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerValidatedSolutions.psm1 b/PowerValidatedSolutions.psm1 index 23dbb753..ba48401e 100644 --- a/PowerValidatedSolutions.psm1 +++ b/PowerValidatedSolutions.psm1 @@ -17424,12 +17424,10 @@ Function Test-ADAuthentication { } if ($principalContext.ValidateCredentials($user, $pass)) { Write-Output "$domain\$user - AD Authentication Successful" - } - else { + } else { Write-Error "$domain\$user - AD Authentication Failed" } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17462,12 +17460,10 @@ Function Get-ADPrincipalGuid { $creds = New-Object System.Management.Automation.PSCredential ($user, $securePassword) $nsxAdminGroupObject = (Get-ADGroup -Server $domain -Credential $creds -Filter { SamAccountName -eq $principal }) $nsxAdminGroupObject - } - else { + } else { Write-Error "Domain User $user Authentication Failed" } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17553,14 +17549,12 @@ Function Get-vCenterServerDetail { $vcenterServer | Add-Member -notepropertyname 'root' -notepropertyvalue ($vcenterCredentialDetails | Where-Object { ($_.credentialType -eq "SSH" -and $_.accountType -eq "USER") }).username $vcenterServer | Add-Member -notepropertyname 'rootPass' -notepropertyvalue ($vcenterCredentialDetails | Where-Object { ($_.credentialType -eq "SSH" -and $_.accountType -eq "USER") }).password $vcenterServer - } - else { + } else { Write-Error "Unable to find Workload Domain type or domain named ($domain) in the inventory of SDDC Manager ($server): PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17628,14 +17622,12 @@ Function Get-NsxtServerDetail { $nsxtCluster | Add-Member -notepropertyname 'nodes' -notepropertyvalue $nsxtServerDetails.nodes } $nsxtCluster - } - else { + } else { Write-Error "Unable to find Workload Domain type or domain named ($domain) in the inventory of SDDC Manager ($fqdn): PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17685,14 +17677,12 @@ Function Get-vRSLCMServerDetail { $vrslcmDetails | Add-Member -notepropertyname 'rootUser' -notepropertyvalue ($vRSLCMCreds | Where-Object { ($_.credentialType -eq "SSH" -and $_.accountType -eq "SYSTEM") }).username $vrslcmDetails | Add-Member -notepropertyname 'rootPassword' -notepropertyvalue ($vRSLCMCreds | Where-Object { ($_.credentialType -eq "SSH" -and $_.accountType -eq "SYSTEM") }).password $vrslcmDetails - } - else { + } else { Write-Error "Unable to obtain VMware Aria Suite Lifecycle details from SDDC Manager ($fqdn), check deployment status: PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17731,25 +17721,26 @@ Function Get-WSAServerDetail { if (Test-VCFConnection -server $fqdn) { if (Test-VCFAuthentication -server $fqdn -user $username -pass $password) { - if (Get-VCFvRA) { + if (Get-VCFWSA) { $vcfWsaDetails = Get-VCFWSA - #$wsaCreds = Get-VCFCredential -resourceName $vcfWsaDetails.fqdn + $wsaCreds = Get-VCFCredential -resourceName $vcfWsaDetails.loadBalancerFqdn $wsaDetails = New-Object -TypeName PSCustomObject $wsaDetails | Add-Member -notepropertyname 'fqdn' -notepropertyvalue $vcfWsaDetails.nodes.fqdn $wsaDetails | Add-Member -notepropertyname 'loadBalancerIpAddress' -notepropertyvalue $vcfWsaDetails.loadBalancerIpAddress $wsaDetails | Add-Member -notepropertyname 'loadBalancerFqdn' -notepropertyvalue $vcfWsaDetails.loadBalancerFqdn + $wsaDetails | Add-Member -notepropertyname 'nodeCount' -notepropertyvalue ($vcfWsaDetails).nodes.Count $wsaDetails | Add-Member -notepropertyname 'node1IpAddress' -notepropertyvalue $vcfWsaDetails.nodes.ipAddress[0] $wsaDetails | Add-Member -notepropertyname 'node2IpAddress' -notepropertyvalue $vcfWsaDetails.nodes.ipAddress[1] $wsaDetails | Add-Member -notepropertyname 'node3IpAddress' -notepropertyvalue $vcfWsaDetails.nodes.ipAddress[2] + $wsaDetails | Add-Member -notepropertyname 'adminUser' -notepropertyvalue $wsaCreds.username + $wsaDetails | Add-Member -notepropertyname 'adminPass' -notepropertyvalue $wsaCreds.password $wsaDetails - } - else { + } else { Write-Error "Unable to obtain Workspace ONE Access details from SDDC Manager ($fqdn), check deployment status: PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17799,14 +17790,12 @@ Function Get-vRAServerDetail { $vraDetails | Add-Member -notepropertyname 'node2IpAddress' -notepropertyvalue $vcfVraDetails.nodes.ipAddress[1] $vraDetails | Add-Member -notepropertyname 'node3IpAddress' -notepropertyvalue $vcfVraDetails.nodes.ipAddress[2] $vraDetails - } - else { + } else { Write-Error "Unable to obtain VMware Aria Automation details from SDDC Manager ($fqdn), check deployment status: PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17864,14 +17853,12 @@ Function Get-vROPsServerDetail { $vropsDetails | Add-Member -notepropertyname 'adminUser' -notepropertyvalue $vropsCreds.username $vropsDetails | Add-Member -notepropertyname 'adminPass' -notepropertyvalue $vropsCreds.password $vropsDetails - } - else { + } else { Write-Error "Unable to obtain VMware Aria Operations details from SDDC Manager ($fqdn), check deployment status: PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17925,14 +17912,12 @@ Function Get-vRLIServerDetail { $vrliDetail | Add-Member -notepropertyname 'adminUser' -notepropertyvalue $vrliCreds.username $vrliDetail | Add-Member -notepropertyname 'adminPass' -notepropertyvalue $vrliCreds.password $vrliDetail - } - else { + } else { Write-Error "Unable to obtain VMware Aria Operations for Logs details from SDDC Manager ($fqdn), check deployment status: PRE_VALIDATION_FAILED" } } } - } - Catch { + } Catch { Debug-ExceptionWriter -object $_ } } @@ -17947,7 +17932,7 @@ Function Get-VCFDnsSearchDomain { The Get-VCFDnsSearchDomain cmdlet gets the search domains configured in an SDDC Manager appliance .EXAMPLE - Get-VCFDnsSearchDomain + Get-VCFDnsSearchDomain -sddcManagerVmName sfo-vcf01 -sddcManagerRootPass VMw@re1! This example gets all search domains configured in an SDDC Manager appliance #> @@ -17958,10 +17943,9 @@ Function Get-VCFDnsSearchDomain { Try { $scriptCommand = "cat /etc/resolv.conf" - try { + Try { $output = Invoke-VMScript -VM $sddcManagerVmName -ScriptText $scriptCommand -GuestUser root -GuestPassword $sddcManagerRootPass -Server $vcfVcenterDetails.fqdn -ErrorAction Stop - } - catch { + } Catch { if ($_.Exception -match "Failed to authenticate with the guest operating system") { $PSCmdlet.ThrowTerminatingError( [System.Management.Automation.ErrorRecord]::new( @@ -17971,8 +17955,7 @@ Function Get-VCFDnsSearchDomain { "" ) ) - } - elseif ($_.Exception -match "Value cannot be found for the mandatory parameter VM" -or $_.Exception -match "Could not find VirtualMachine with name") { + } elseif ($_.Exception -match "Value cannot be found for the mandatory parameter VM" -or $_.Exception -match "Could not find VirtualMachine with name") { $PSCmdlet.ThrowTerminatingError( [System.Management.Automation.ErrorRecord]::new( ([System.Management.Automation.ItemNotFoundException]"Retrieving DNS search domains from SDDC Manager - invalid SDDC Manager appliance name: PRE_VALIDATION_FAILED"), @@ -17990,8 +17973,7 @@ Function Get-VCFDnsSearchDomain { $searchDomains += $item } } - } - Catch { + } Catch { Write-Error $_.Exception.Message }