add CiscoUCSCentral

This commit is contained in:
OCram85 2022-07-19 14:18:24 +02:00
parent b76668c1e7
commit f2ed54ce34
2 changed files with 60 additions and 11 deletions

View File

@ -15,7 +15,16 @@ function Connect-To {
.PARAMETER Type
Specify the host type of the target. Currently implemented targets are: Possible connection values are:
CiscoUcs, FTP, NetAppFAS, VMware, CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
- CiscoUcs
- CiscoUcsCentral
- CisServer
- ExchangeHTTP
- ExchangeHTTPS
- FTP
- NetAppFAS
- SCP
- VMware
.PARAMETER Credentials
Use this parameter to bypass the stored credentials. Without this parameter Connect-To tries to read the
@ -41,6 +50,9 @@ function Connect-To {
.EXAMPLE
Connect-To -RemoteHost "ucs.myside.local" -Type CiscoUcs
.EXAMPLE
Connect-To -RemoteHost "ucscentral.myside.local" -Type 'CiscoUcsCentral'
.EXAMPLE
Connect-To -RemoteHost "ftp.myside.local" -Type FTP
@ -79,6 +91,7 @@ function Connect-To {
[Parameter(Mandatory = $true, ParameterSetName = 'Private')]
[ValidateSet(
'CiscoUcs',
'CiscoUcsCentral',
'FTP',
'NetAppFAS',
'VMware',
@ -189,6 +202,20 @@ function Connect-To {
Write-Error @MessageParams
}
}
"CiscoUcsCentral" {
try {
$handle = Connect-UcsCentral -Name $RemoteHost -Credential $creds -NotDefault
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcsCentral', $handle)
}
catch {
$MessageParams = @{
Message = ('Unable to connect to {0} using {1}' -f $RemoteHost, $Type)
ErrorAction = 'Stop'
}
Write-Error @MessageParams
}
}
"FTP" {
# First establish the FTP session
$WinSCPConParams = @{

View File

@ -14,8 +14,17 @@ function Disconnect-From {
same hostname.
.PARAMETER Type
Specify the host type of the target. Currently implemented targets are: CiscoUcs, FTP, NetAppFAS, VMware,
CisServer, ExchangeHTTP, ExchangeHTTPS, SCP.
Specify the host type of the target. Currently implemented targets are:
- CiscoUcs
- CiscoUcsCentral
- FTP
- NetAppFAS
- VMware
- CisServer
- ExchangeHTTP
- ExchangeHTTPS
- SCP
.PARAMETER Force
Force the disconnect, even if the disconnect would fail.
@ -64,6 +73,7 @@ function Disconnect-From {
[Parameter(Mandatory = $true)]
[ValidateSet(
'CiscoUcs',
'CiscoUcsCentral',
'FTP',
'NetAppFAS',
'VMware',
@ -85,10 +95,10 @@ function Disconnect-From {
"VMware" {
try {
if ($Force) {
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop' -Force:$true
}
else {
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
Disconnect-VIServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop'
}
}
@ -104,10 +114,10 @@ function Disconnect-From {
"CisServer" {
try {
if ($Force) {
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop -Force:$true
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop' -Force:$true
}
else {
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction Stop
Disconnect-CisServer -Server $RemoteHost -Confirm:$false -ErrorAction 'Stop'
}
}
@ -171,10 +181,24 @@ function Disconnect-From {
Write-Error @MessageParams
}
}
"CiscoUCSCentral" {
try {
$handle = Connect-UcsCentral -Name $RemoteHost -Credential $creds -NotDefault
$ExecutionContext.SessionState.PSVariable.Set('DefaultUcsCentral', $handle)
}
catch {
$MessageParams = @{
Message = "Unable to disconnect from {0} using Type {1}." -f $RemoteHost, $Type
ErrorAction = 'Stop'
}
Write-Error @MessageParams
}
}
"ExchangeHTTP*" {
try {
Get-Variable -Name 'PSExchangeRemote' -Scope Global -ErrorAction Stop
Remove-PSSession -Session $Global:PSExchangeRemote -ErrorAction Stop
Get-Variable -Name 'PSExchangeRemote' -Scope 'Global' -ErrorAction 'Stop'
Remove-PSSession -Session $Global:PSExchangeRemote -ErrorAction 'Stop'
}
catch {
$MessageParams = @{
@ -206,6 +230,4 @@ function Disconnect-From {
}
}
}
end {}
}