functions/Unlock-PasswordVault.ps1

function Unlock-PasswordVault
{
    <#
.SYNOPSIS
Unlock-PasswordVault

.Description
Unlock a BitWarden or a VaultWarden database.

.EXAMPLE
Unlock-PasswordVault

.NOTES
Name: Unlock-PasswordVault
Author: Felix Scholz
Version: 0.0.1.0
DateCreated: 2024-01-29

.COMPONENT
Requires PSEdition Core
Requires Version 7.0 or above
#>

    [CmdletBinding()]
    param()
    BEGIN {
    }
    PROCESS {
        $Token = $( bw unlock --raw )

        Write-Verbose -Message "The token is $Token"
        [Environment]::SetEnvironmentVariable('BW_SESSION', "$Token", 'User')
        $_ = $( New-Item -Path Env:\BW_SESSION -Value "$Token" -Force )

    }
    END {
    }
}