SecretManagement.DevolutionsHub.Extension/private/Disconnect-DevolutionsHub.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using namespace Microsoft.PowerShell.SecretManagement
using namespace Devolutions.Hub.PowerShell

function Disconnect-DevolutionsHub {
    [CmdletBinding()]
    param(
        $hubParameters
    )
    
    $hubContext = Get-HubContext | Where-Object {$_.ApplicationKey -eq $hubParameters.ApplicationKey} | Select-Object -First 1
    if ($null -eq $hubContext)
    {
        Write-Verbose 'Not connected' -Verbose:$verboseEnabled
        return
    }

    Disconnect-HubAccount -ApplicationKey $hubParameters.ApplicationKey;
    Write-Verbose 'Disconnected' -Verbose:$verboseEnabled
}