Sort the connection list

This commit is contained in:
pinguinfuss 2023-03-09 13:10:54 +01:00
parent 56727afa3e
commit f27f1faad7

View File

@ -18,13 +18,13 @@ function Connect-To {
- CiscoUcs - CiscoUcs
- CiscoUcsCentral - CiscoUcsCentral
- CisServer
- ExchangeHTTP - ExchangeHTTP
- ExchangeHTTPS - ExchangeHTTPS
- FTP - FTP
- NetAppFAS - NetAppFAS
- SCP - SCP
- VMware - VMware
- VMwareCisServer
.PARAMETER Credentials .PARAMETER Credentials
Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the
@ -94,13 +94,13 @@ function Connect-To {
[ValidateSet( [ValidateSet(
'CiscoUcs', 'CiscoUcs',
'CiscoUcsCentral', 'CiscoUcsCentral',
'FTP',
'NetAppFAS',
'VMware',
'CisServer',
'ExchangeHTTP', 'ExchangeHTTP',
'ExchangeHTTPS', 'ExchangeHTTPS',
'SCP' 'FTP',
'NetAppFAS',
'SCP',
'VMware',
'VMwareCisServer'
)] )]
[string] $Type, [string] $Type,
@ -212,6 +212,46 @@ function Connect-To {
Write-Error @MessageParams Write-Error @MessageParams
} }
} }
'ExchangeHTTP' {
try {
$ConnectionParams = @{
ConnectionURI = 'http://{0}/powershell' -f $RemoteHost
ConfigurationName = 'Microsoft.Exchange'
Credential = $creds
ErrorAction = 'Stop'
}
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
# ScriptAnalyzer issue (unused var) workaround.
$null = $Global:PSExchangeRemote
}
catch {
# Write a error message to the log.
$MessageParams = @{
Message = 'Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type
ErrorAction = 'Stop'
}
Write-Error @MessageParams
}
}
'ExchangeHTTPS' {
try {
$ConnectionParams = @{
ConnectionURI = 'https://{0}/powershell' -f $RemoteHost
ConfigurationName = 'Microsoft.Exchange'
Credential = $creds
ErrorAction = 'Stop'
}
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
}
catch {
# Write a error message to the log.
$MessageParams = @{
Message = 'Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type
ErrorAction = 'Stop'
}
Write-Error @MessageParams
}
}
'FTP' { 'FTP' {
# First establish the FTP session # First establish the FTP session
$WinSCPConParams = @{ $WinSCPConParams = @{
@ -268,7 +308,7 @@ function Connect-To {
Write-Error @MessageParams Write-Error @MessageParams
} }
} }
'CisServer' { 'VMwareCisServer' {
try { try {
if ($PassThru.IsPresent) { if ($PassThru.IsPresent) {
Connect-CisServer -Server $RemoteHost -Credential $creds -ErrorAction Stop Connect-CisServer -Server $RemoteHost -Credential $creds -ErrorAction Stop
@ -288,46 +328,6 @@ function Connect-To {
Write-Error @MessageParams Write-Error @MessageParams
} }
} }
'ExchangeHTTP' {
try {
$ConnectionParams = @{
ConnectionURI = 'http://{0}/powershell' -f $RemoteHost
ConfigurationName = 'Microsoft.Exchange'
Credential = $creds
ErrorAction = 'Stop'
}
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
# ScriptAnalyzer issue (unused var) workaround.
$null = $Global:PSExchangeRemote
}
catch {
# Write a error message to the log.
$MessageParams = @{
Message = 'Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type
ErrorAction = 'Stop'
}
Write-Error @MessageParams
}
}
'ExchangeHTTPS' {
try {
$ConnectionParams = @{
ConnectionURI = 'https://{0}/powershell' -f $RemoteHost
ConfigurationName = 'Microsoft.Exchange'
Credential = $creds
ErrorAction = 'Stop'
}
$Global:PSExchangeRemote = New-PSSession @ConnectionParams
}
catch {
# Write a error message to the log.
$MessageParams = @{
Message = 'Unable to connect to {0} using Type {1}.' -f $RemoteHost, $Type
ErrorAction = 'Stop'
}
Write-Error @MessageParams
}
}
'SCP' { 'SCP' {
$WinSCPSessionParams = @{ $WinSCPSessionParams = @{
Credential = $creds Credential = $creds