From 98a50d76302741a74fb9d4ec159f107b5b4f4d79 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Tue, 6 Mar 2018 14:40:06 +0100 Subject: [PATCH] adds scp disconnect --- src/Connection/Disconnect-From.ps1 | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Connection/Disconnect-From.ps1 b/src/Connection/Disconnect-From.ps1 index abc864b..3da3fe4 100644 --- a/src/Connection/Disconnect-From.ps1 +++ b/src/Connection/Disconnect-From.ps1 @@ -22,6 +22,8 @@ function Disconnect-From { - CisServer Terminates the connection from a Vmware CisServer. - ExchangeHTTP Remove the existing remote session to the given Exchange server - ExchangeHTTPS Remove the existing remote session to the given Exchange server + - SCP Terminates the existing SCP session. + .PARAMETER Force Force the disconnect, even if the disconnect would fail. @@ -70,7 +72,16 @@ function Disconnect-From { [string]$RemoteHost, [Parameter(Mandatory = $true)] - [ValidateSet('CiscoUcs', 'FTP', 'NetAppFAS', 'VMware', 'CisServer', 'ExchangeHTTP', 'ExchangeHTTPS')] + [ValidateSet( + 'CiscoUcs', + 'FTP', + 'NetAppFAS', + 'VMware', + 'CisServer', + 'ExchangeHTTP', + 'ExchangeHTTPS', + 'SCP' + )] [string]$Type, [Parameter(Mandatory = $false)] @@ -178,6 +189,18 @@ function Disconnect-From { Write-Error @MessageParams } } + "SCP" { + if ($Global:WinSCPSession.Opened) { + Remove-WinSCPSession -WinSCPSession $Global:WinSCPSession + } + else { + $MessageParams = @{ + Message = "There is no open WinSCP Session" + ErrorAction = "Stop" + } + Write-Error @MessageParams + } + } default { # Write a error message to the log. $MessageParams = @{