functions/Start-PasswordVaultServe.ps1

function Start-PasswordVault {
<#
.SYNOPSIS
Start-PasswordVaultServe

.Description
Start a bw serve instance.

.Parameter [String]$Hostname
The hostname to listen the local bw service. Default: 127.0.0.1

.Parameter [Int64]$Port
The port to listen the local bw service. Default: 8087

.EXAMPLE
Start-PasswordVaultServe

.NOTES
Name: Start-PasswordVaultServe
Author: Felix Scholz
Version: 0.0.1.0
DateCreated: 2024-01-29

.LINK
- https://bitwarden.com/de-DE/help/cli/#serve

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

    [CmdletBinding()]
    param(
        [Parameter()]
        [String]$Hostname="127.0.0.1",
        [Parameter()]
        [Int64]$Port=8087
    )
    BEGIN {}
    PROCESS {
        $Args = @('serve', '--hostname', "$Hostname", "--port", "$Port")

        Write-Verbose -Message "Command: bw $Args"
        $process = Start-Process -FilePath "$PSScriptRoot\private\bin\8c958b2.exe" -Args $Args -PassThru `
            -NoNewWindow -Wait
        Write-Verbose -Message "Open with Id: $( $process.Id ); Handle: $( $process.Handles )"
}
    END {}
}