Multiple CLI sessions on the same host

Dear community,

I am using multiple Gitlab pipelines to run 4 PowerShell scripts on a Windows host on an hourly basis. These scripts differ in functionality but all require access to the Bitwarden vault, to read or update vault items. The issue comes in as some of these scripts run at the same time and the CLI only supports one active session on a host. So script A starts, logs into the vault, unlocks it and then runs a series of vault item updates. While that is happening script B starts and “steals” the CLI session from script A, causing said script to fail.

I would like to avoid to built a queuing logic in my pipelines just for CLI sessions. Is there a smart way to allow multiple, concurrent CLI sessions on the same host?

I was looking at running a service on the host with “bw serve”. However that would probably mean there is an unlocked vault at all times on the host, which is not ideal from a security point of view.

Thankful for any hints.

Kind regards,

I haven’t tried it myself, nor do I know if it also applies to windows cli.

Dear @kpiris,

You are a gentleman and a scholar. This works, thanks a lot. The session really comes down to the data.json file. If I use different files for each script, they run without stealing each others session. Here’s my code for future reference:

$env:BITWARDENCLI_APPDATA_DIR = "$env:APPDATA\Bitwarden CLI\$($MyInvocation.MyCommand.Name)"

Kind regards,