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

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

function Connect-DevolutionsHub {
    [CmdletBinding()]
    param(
        $hubParameters
    )
    
    if (-not $hubParameters.VaultId) {
        throw "VaultId not found! Please configure a Hub VaultId to your SecretVault."
    }

    $PSHubContext = [Devolutions.Hub.PowerShell.Entities.PowerShell.PSHubContext] @{
        ApplicationKey    = $hubParameters.ApplicationKey; 
        ApplicationSecret = $hubParameters.ApplicationSecret; 
        Url               = $hubParameters.Url
    }

    Write-Verbose 'Connecting to Hub' -Verbose:$verboseEnabled
    Connect-HubAccount -PSHubContext $PSHubContext;
    Write-Verbose 'Connected to Hub' -Verbose:$verboseEnabled
}