Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitwarden Powershell Issues #77

Open
djarbz opened this issue Aug 9, 2023 · 2 comments
Open

Bitwarden Powershell Issues #77

djarbz opened this issue Aug 9, 2023 · 2 comments

Comments

@djarbz
Copy link

djarbz commented Aug 9, 2023

I was excited to see this script pop up the other day.

I suggest adding this to the header of the script:

#Requires -Version 7.2

# To use PWSH v7
# Open File > Options > Advanced > Dynamic Folder
# Set the path to "%ProgramFiles%\PowerShell\7\pwsh.exe"

$PSStyle.OutputRendering = 'PlainText' was introduced in v7.2.

Also, I am unable to get past the check for the bw executable.

If I run the following in my terminal it works fine, but setting that path in the Custom Property field it will error out.

$path = "$env:ONEDRIVECONSUMER\AppSync\RoyalTS\bw.exe"

if (!(Test-Path -Path "$($path)" -PathType Leaf)) {
  Write-Error -Message "Bitwarden CLI utility not found at specified path. Please check CLI utility path in Custom Properties." -ErrorAction Stop
}

Further testing, I exported env: to a log file and it shows the correct values.

@GrinGrin
Copy link

Hi @djarbz ,

You're right, the OutputRendering is only in 7.2+ and that break usability with 5.1. As it is not a mandatory, I can either add a condition for the PowerShell version to include this only with 7.2+ or simply delete the line as the result seems not impacted if not present with 7.2+.

For the $env not resolved correctly it may be because of how the script get it:

$Bitwarden = ( New-Object PSObject |
  Add-Member -PassThru NoteProperty exec_path '$CustomProperty.BitWardenCLIExecutable$' |
  Add-Member -PassThru NoteProperty serverUrl '$CustomProperty.BitWardenServerURL$' |
  Add-Member -PassThru NoteProperty clientId '$CustomProperty.APIClientID$' |
  Add-Member -PassThru NoteProperty clientSecret '$CustomProperty.APIClientSecret$' |
  Add-Member -PassThru NoteProperty password '$CustomProperty.AccountPassword$' |
  Add-Member -PassThru NoteProperty session '' )

As I use RoyalTS Tokens replacement, I had to use single quotes to prevent PowerShell from attempting to expand $CustomProperty.xxx$ incorrectly.
Unfortunately this block variables expansion link $env that can be set in the property field. I'll try to find another way to evaluate the value set correctly before use.

I'll keep you tuned with update if I find a patch for those issues !

Best Regards,
Nicolas.

@djarbz
Copy link
Author

djarbz commented Feb 6, 2024

Even if we could use/resolve the environment pre-token replacement such as variables are used in other fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants