Skip to content

Commit

Permalink
Fix get-cred-password
Browse files Browse the repository at this point in the history
  • Loading branch information
jawilson committed Mar 29, 2024
1 parent aacd018 commit c192f63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion oh-my-zsh/dotfiles-custom/005-os-specific.zsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if [[ "$OSTYPE" == "msys" || -e "/proc/sys/fs/binfmt_misc/WSLInterop" ]]; then
if powershell.exe -Command "if(-Not (Get-Command Get-StoredCredential -errorAction SilentlyContinue)) { exit 1; }" &> /dev/null; then
alias get-cred-password='f () { powershell.exe -Command "\$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR((Get-StoredCredential -Target LegacyGeneric:target=$1).Password); [System.Runtime.InteropServices.Marshal]::PtrToStringAnsi(\$BSTR); [Runtime.InteropServices.Marshal]::ZeroFreeBSTR(\$BSTR)"}; f'
alias get-cred-password='f () { powershell.exe -Command "\$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR((Get-StoredCredential -Target LegacyGeneric:target=$1).Password); [System.Runtime.InteropServices.Marshal]::PtrToStringAuto(\$BSTR); [Runtime.InteropServices.Marshal]::ZeroFreeBSTR(\$BSTR)"}; f'
else
alias get-cred-password='echo "Get-StoredCredential not found, run 'Install-Module CredentialManager' in an elevated PowerShell session to install it"'
fi
Expand Down

0 comments on commit c192f63

Please sign in to comment.