Implement CiscoUcsCentral provider to Connect-To #54
@ -109,6 +109,11 @@ function Connect-To {
|
|||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# Set defaults for the preference variables.
|
||||||
|
$InformationPreference = 'Continue'
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
# Set the CredentialStore for private, shared or custom mode.
|
# Set the CredentialStore for private, shared or custom mode.
|
||||||
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
Write-Debug ("ParameterSetName: {0}" -f $PSCmdlet.ParameterSetName)
|
||||||
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
if ($PSCmdlet.ParameterSetName -eq "Private") {
|
||||||
@ -122,7 +127,7 @@ function Connect-To {
|
|||||||
|
|
||||||
# First check the optional modules
|
# First check the optional modules
|
||||||
if (-not (Resolve-Dependency -Name $Type)) {
|
if (-not (Resolve-Dependency -Name $Type)) {
|
||||||
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f $Type) -ErrorAction 'Stop'
|
Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f $Type)
|
||||||
}
|
}
|
||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
"VMware" {
|
"VMware" {
|
||||||
@ -153,11 +158,8 @@ function Connect-To {
|
|||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$m = "Unable to look up credential store item for {0}/Identifier {1}!" -f $RemoteHost, $Identifier
|
||||||
Message = "Unable to look up credential store item for RemoteHost {0}/Identifier {1}!" -f $RemoteHost, $Identifier
|
Write-Error -Message $m
|
||||||
ErrorAction = "Stop"
|
|
||||||
}
|
|
||||||
Write-Error @MessageParams
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -165,11 +167,7 @@ function Connect-To {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($creds.UserName -eq "" -or $creds.Password.GetType().Name -ne "SecureString") {
|
if ($creds.UserName -eq "" -or $creds.Password.GetType().Name -ne "SecureString") {
|
||||||
$MessageParams = @{
|
Write-Error -Message ("Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost)
|
||||||
Message = "Please provide valid credentials for RemoteHost {0}!" -f $RemoteHost
|
|
||||||
ErrorAction = "Stop"
|
|
||||||
}
|
|
||||||
Write-Error @MessageParams
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch ($Type) {
|
switch ($Type) {
|
||||||
@ -180,11 +178,19 @@ function Connect-To {
|
|||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
$MessageParams = @{
|
$_.Exception.Message | Write-Warning
|
||||||
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)
|
||||||
ErrorAction = "Stop"
|
|
||||||
}
|
}
|
||||||
Write-Error @MessageParams
|
}
|
||||||
|
'CiscoUcsCentral' {
|
||||||
|
try {
|
||||||
|
$handle = Connect-UcsCentral -Name $RemoteHost -Credential $creds -NotDefault
|
||||||
|
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcsCentral', $handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
catch {
|
||||||
|
$_.Exception.Message | Write-Warning
|
||||||
|
Write-Error -Message ('Unable to connect to {0} using {1}' -f $RemoteHost, $Type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"FTP" {
|
"FTP" {
|
||||||
|
Loading…
Reference in New Issue
Block a user