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