functions/Unlock-BitWarden.ps1

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

.Description
Unlock a BitWarden or a VaultWarden database.

.EXAMPLE
Unlock-BitWarden

.NOTES
Name: Unlock-BitWarden
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 {
    }
}