I was finally able to figure this out without going by the documentation. Not sure if it is the recommended course action but I haven’t seen a post from Bitwarden addressing this issue and answering other questions regarding the process.
In order for the desktop application to contain your organizations self hosted URL, you must write a script and tweak it so the data.json file overwrites the current one in %AppData%\Bitwarden. We edited the data.json file to contain only the information that pertains to the installation. Erase all the content in the default data.json file from a previous manual installation, (you will use that data.json file as a template for other installs) and paste the json code below into the blank data.json file. Make sure to fill in your self hosted URL in the “base”: field.
{
“global”: {
“theme”: “system”,
“window”: {},
“stateVersion”: 1,
“environmentUrls”: {
“base”: “https://bitwarden.company.com”,
“api”: null,
“identity”: null,
“webVault”: null,
“icons”: null,
“notifications”: null,
“events”: null,
“keyConnector”: null
},
“region”: “Self-hosted”
}
}
After editing the json file to resemble the json above we then went into PowerShell to script the installation and the copy of the json file to create the directory when the application is installed.
#Specify paths
$installerPath = “Bitwarden-Installer-2023.8.2.exe”
$installationArguments = “/allusers /S”
$bitwardenExePath = “C:\Program Files\Bitwarden\Bitwarden.exe”
$sourceFilePath = “data.json”
#Construct the full path using environment variables
$bitwardenFolderPath = Join-Path $env:AppData “Bitwarden”
$destinationFilePath = Join-Path $bitwardenFolderPath “data.json”
#Create Bitwarden folder and copy json file
$Users = (Get-ChildItem C:\Users).Name
ForEach($User in $Users) {
New-Item -Path "C:\Users$User\AppData\Roaming" -Name “Bitwarden” -ItemType “directory” -ErrorAction SilentlyContinue
Copy-item $sourceFilePath -destination “C:\Users$user\AppData\Roaming\Bitwarden”
}
#Start the installation process
Start-Process -FilePath $installerPath -ArgumentList $installationArguments -Wait
Once you have copied the script into PowerShell and name it Install-Bitwarden.ps1 you will need to package the other files to prepare for the deplopyment. You will need the json file you edited to resemble the json code pasted above, you have the PowerShell script created and it’s been tested, and the executable for the desktop application. You then can zip those three files together and begin deploying it to your organization.
Since the directory isn’t created until the application is ran, this script will create and place the data.json file in the directory. Once that is done the application will install and the directory will reamain blank. Run the application once the script is done and confirm that the self hosted information is pasted in the desktop application
Hopefully that helps!