Skip to content

Commit

Permalink
chore: code formatting for ad and cloud foundation functions (#418)
Browse files Browse the repository at this point in the history
- 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 <gblake@vmware.com>
  • Loading branch information
GaryJBlake authored Nov 30, 2023
1 parent 1092cdb commit 44ec63f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 47 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion PowerValidatedSolutions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand Down
74 changes: 28 additions & 46 deletions PowerValidatedSolutions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand Down Expand Up @@ -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 $_
}
}
Expand All @@ -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
#>

Expand All @@ -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(
Expand All @@ -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"),
Expand All @@ -17990,8 +17973,7 @@ Function Get-VCFDnsSearchDomain {
$searchDomains += $item
}
}
}
Catch {
} Catch {
Write-Error $_.Exception.Message
}

Expand Down

0 comments on commit 44ec63f

Please sign in to comment.