More reordering/cleanup

This commit is contained in:
pinguinfuss 2023-03-09 20:16:31 +01:00
parent a5b430e4ae
commit 22631f2836

View File

@ -264,38 +264,30 @@ function Connect-To {
} }
} }
'NetAppFAS' { 'NetAppFAS' {
# Construct the splatting for Connect-NcController
$params = @{
Name = $RemoteHost
Credential = $creds
HTTPS = $true
}
# Check if -PassThru was passed. If so, a) do not set the default variable and b) return the
# session object to the caller.
if ($PSBoundParameters.ContainsKey('PassThru')) {
$params.Add('Transient', $true)
}
try { try {
$null = Connect-NcController -Name $RemoteHost -Credential $creds -ErrorAction Stop -HTTPS $handle = Connect-NcController @params
} }
catch { catch {
# Write a error message to the log. # Write a error message to the log.
Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type) Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type)
} }
}
'VMware' {
try {
Connect-VIServer -Server $RemoteHost -Credential $creds -ErrorAction Stop | Out-Null
}
catch { if ($PSBoundParameters.ContainsKey('PassThru')) {
# Write a error message to the log. return $handle
Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type)
}
}
'VMwareCisServer' {
try {
if ($PassThru.IsPresent) {
Connect-CisServer -Server $RemoteHost -Credential $creds
}
else {
$null = Connect-CisServer -Server $RemoteHost -Credential $creds
}
}
catch {
# Write a error message to the log.
Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type)
} }
} }
'SCP' { 'SCP' {
@ -324,6 +316,31 @@ function Connect-To {
Write-Error -Message $m Write-Error -Message $m
} }
} }
'VMware' {
try {
Connect-VIServer -Server $RemoteHost -Credential $creds -ErrorAction Stop | Out-Null
}
catch {
# Write a error message to the log.
Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type)
}
}
'VMwareCisServer' {
try {
if ($PassThru.IsPresent) {
Connect-CisServer -Server $RemoteHost -Credential $creds
}
else {
$null = Connect-CisServer -Server $RemoteHost -Credential $creds
}
}
catch {
# Write a error message to the log.
Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type)
}
}
default { default {
# Write a error message to the log. # Write a error message to the log.
Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type) Write-Error -Message ('Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type)