PowerShell connect to password protected vault

Resolved Implemented

PowerShell connect to password protected vault

avatar

Hi

I'm trying to write a script which automatically connects to our data source (SQL server) for RDM using the Devolutions PowerShell module. This will prompt to enter the password for the vault: "This vault is password protected. Please enter the password to access it."

This seems to be just an input read from the console. Is there any parameter I can pass the password to or another cmdlet to use?

Cheers
Alex

All Comments (11)

avatar

Hello Alex,

Thank you for contacting the Devolutions support team.

Could you tell me if you already tried the Get-Crendetial cmdlet in your script?
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-7.4

Best regards,

Patrick Ouimet

avatar
Hello Alex,

Thank you for contacting the Devolutions support team.

Could you tell me if you already tried the Get-Crendetial cmdlet in your script?
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-7.4

Best regards,


Hi,

I couldn't find where to pass the credentials to.

For example when just running

PS > Get-RDMSession -ID ae42b2c1-33ca-479b-b87e-bbc91ec5db99 | Select Name, Description, Host
This vault is password protected. Please enter the password to access it.
*********


It would prompt for the password but not with Get-Credetial, instead it looks like it's using Read-Host.
I couldn't find any other parameter or cmdlet to enter this password before running Get-RDMSession.

I'm using the latest PowerShell module and PowerShell 7.

Thanks

avatar

Hello Alex,

After spending a long time testing, I found out that the read-host command cannot be prefilled. It requires user interaction to work.

For your situation, one way to bypass this is by using the 'SendKeys' method. This method can simulate keystrokes to input your password into the console.

Here’s a basic example of how you might use it:
$Host.UI.RawUI.FlushInputBuffer()
[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
[System.Windows.Forms.SendKeys]::SendWait('YourPassword{ENTER}')

Please replace 'YourPassword' with your actual password. However, keep in mind that this method simulates actual keystrokes, so ensure that the PowerShell window is active and in the foreground when you run the script to prevent your password from being sent to unintended applications.

Use this approach carefully, and consider the security implications, especially in production environments.

Let me know if this solution works for you or if you need further assistance.

Best regards,

Patrick Ouimet

avatar

Hi Patrick

Thanks, unfortunately I am planning on running this in the background so this won't work.
I am guessing there are no other ways, can this be made into a feature request for the next version?

Cheers
Alex

avatar

Hello Alex,

This task is on our to-do list, and I will prioritize it. We will keep you informed of the progress.

Best regards,
Maxime

avatar

Hi Maxime

Thanks, I saw a new version releases but didn't see this feature in the notes. Do you know which version will have this change?

Cheers,
Alex

avatar

Hello Alex,

The next version, 2024.2.1, is expected to include this feature. In the worst-case scenario, it will be part of the 2024.2.2 release.

Best regards,
Maxime

avatar

Hello Alex,

In version 2024.2.1 of the module, we have introduced the cmdlet Unlock-RDMRepository. This cmdlet is designed to unlock the next protected vault. Additionally, we have added the property IsPasswordProtected to the vault object to identify which ones are protected.

If you need any further assistance, please feel free to reach out.

Best regards,
Maxime

avatar

hi - using PS Devolutions.PowerShell module ver 2024.3.11
get prompted for password when executing below snippet, but the password never seems to get passed as the snippet repeatedly prompts for the password
There doesn't seem to be a way to pass credentials into Get-RDMSession

Get-RDMSession -GroupName 'SomeGroup' -IncludeSubFolders

avatar

Hello,

I am unable to reproduce the issue. The behavior you described suggests that an invalid password may have been used. Could you try using a new password? I will continue testing to determine whether certain characters might be causing issues. Could you also specify which data source you are trying to connect to (DVLS, MSSQL, etc.)?

Best regards,
Maxime

avatar
Hello,

I am unable to reproduce the issue. The behavior you described suggests that an invalid password may have been used. Could you try using a new password? I will continue testing to determine whether certain characters might be causing issues. Could you also specify which data source you are trying to connect to (DVLS, MSSQL, etc.)?

Best regards,
Maxime


thanks for the reply.
looks like issue was an anomoly and has fixed itself after a password reset