Implement StorageGRID connection #79

Open
pinguinfuss wants to merge 23 commits from pinguinfuss/PSCredentialStore:ConnectTo-StorageGRID into master
Showing only changes of commit f27f1faad7 - Show all commits

View File

@ -18,13 +18,13 @@ function Connect-To {
- CiscoUcs
- CiscoUcsCentral
- CisServer
- ExchangeHTTP
- ExchangeHTTPS
- FTP
- NetAppFAS
- SCP
- VMware
- VMwareCisServer
.PARAMETER Credentials
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(
'CiscoUcs',
'CiscoUcsCentral',
'FTP',
'NetAppFAS',
'VMware',
'CisServer',
'ExchangeHTTP',
'ExchangeHTTPS',
'SCP'
'FTP',
'NetAppFAS',
'SCP',
'VMware',
'VMwareCisServer'
)]
[string] $Type,
@ -212,6 +212,46 @@ function Connect-To {
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' {
# First establish the FTP session
$WinSCPConParams = @{
@ -268,7 +308,7 @@ function Connect-To {
Write-Error @MessageParams
}
}
'CisServer' {
'VMwareCisServer' {
try {
if ($PassThru.IsPresent) {
Connect-CisServer -Server $RemoteHost -Credential $creds -ErrorAction Stop
@ -288,46 +328,6 @@ function Connect-To {
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' {
$WinSCPSessionParams = @{
Credential = $creds