src/Import-CsKeyVaultStore.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<#
.SYNOPSIS
    Imports a Credential from Azure KeyVault to a local CredentialStore file
.DESCRIPTION
    Import a Credential from Azure KeyVault to a local CredentialStore file
.PARAMETER VaultName
    The name of the Azure KeyVault
.PARAMETER FilePath
    Specifies the path to the CredentialStore file
.LINK
    https://github.com/fodonnel/CredentialStore
#>

function Import-CsKeyVaultStore {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true, Position = 0)]
        [string] $VaultName,

        [Parameter(Mandatory = $false, Position = 1)]
        [Alias("File")]
        [string] $FilePath
    )

    $entries = Get-CsKeyVaultEntry -VaultName $VaultName 
    Initialize-CsStore -FilePath $FilePath
    $entries | Set-CsEntry -FilePath $FilePath
}