Forum / Remote Desktop Manager - PowerShell Repository

Get entry credentials for use in powershell script

  • Create an Issue
  • Cancel

Hi

Right now I've figured out how to use the user/pass of a credential entry by using "Get-RDMSession -Name "CredentialEntryName" and pointing to the specific credential entry I wanna use in the script. But if I've already set a specific credential on the entry itself, is it possible to make the script just get the name from there, so that I can easily use the same script on many different tenants, where all I have to do is change name and credential on the entry itself?


thanks

Clock3 mths

Hello,

I have moved your thread into the Powershell section and assigned my colleague Alex on the ticket.
It should get back to you tomorrow regarding this.

Best regards,



Jeff Dagenais

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on June 24 and July 1st, 2019.

signaturesignature

Clock3 mths

Hello,

I don't know if it's exactly what you are looking for, but it will at the very least give you a good place to start.
As you mentioned, you can get a credential entry using the Get-RDMSession function.
You can also get the credential entry of a given session (PSConnection)
Here's what I have in mind :
#get the session
$s = Get-RDMSession -Name "<the name of your session>"
#get the credential entry ID associated to a Session
$cred_id = Get-RDMSessionCredentials -GetID -PSConnection $s
#then get the entry itself:
$cred_entry = Get-RDMSession | where-object {$_.ID -eq $cred_id}

The variable $cred_entry should now contain the credential entry associated with the given session.
This technique will work if it's a credential entry associated to an entry.

You might want to take a look here:
https://forum.devolutions.net/topic23912-programmatically-assigning-various-credentials-to-entries.aspx
This will help you define how the credentials are assigned to the session, and reversibly, assigning credentials to entries.

I hope this helps.

Best regards,



Alex Belisle

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on June 24 and July 1st, 2019.

signaturesignature

Clock3 mths

Alexandre Bélisle wrote:

Hello,

I don't know if it's exactly what you are looking for, but it will at the very least give you a good place to start.
As you mentioned, you can get a credential entry using the Get-RDMSession function.
You can also get the credential entry of a given session (PSConnection)
Here's what I have in mind :
#get the session
$s = Get-RDMSession -Name "<the name of your session>"
#get the credential entry ID associated to a Session
$cred_id = Get-RDMSessionCredentials -GetID -PSConnection $s
#then get the entry itself:
$cred_entry = Get-RDMSession | where-object {$_.ID -eq $cred_id}

The variable $cred_entry should now contain the credential entry associated with the given session.
This technique will work if it's a credential entry associated to an entry.

You might want to take a look here:
https://forum.devolutions.net/topic23912-programmatically-assigning-various-credentials-to-entries.aspx
This will help you define how the credentials are assigned to the session, and reversibly, assigning credentials to entries.

I hope this helps.


Best regards,


Hi Alexandre

Thank you for the reply and suggestion.

It's exactly the part where we use Get-RDMSession -Name "<the name of your session>" where I was hoping that it could be possible to automatically "get" the name of the credential set on the powershell entry itself, so that the script does not need to be changed.


Basically I'm making a powershell entry where I connect to Office 365 on multiple tenants. It works but I have to input the credential entry that contains the o365 admin user/pass. Easiest would be if the script could be the same on all tenants.

I hope what I'm writing makes sense.

Clock3 mths

Hello,

I think you could achieve this with a Macro/Script/Tools -> Powershell(Local)
you can take a look here: https://help.remotedesktopmanager.com/macroscripttools_powershelllocal.htm

On my side, I "coded" a one-liner that display the password of a session:
write-host $PASSWORD$

On the Macro/Script/Tools -> PowerShell(Local), in General->Advanced, I checked the LoadRDM CmdLet, and on the credential entry, In Advanced, I ticked the "Allow Password in Variable" to be able to access the said password.

This is of course the simplest purpose of it, but you will find quite easily the availbale variables for entries (for instance, $NAME$ will refer to the Session Name).

Thoughts?

Regards,



Alex Belisle

OFFICE CLOSURE!
Although our various support queues will be monitored for emergencies, Devolutions' offices will be closed on June 24 and July 1st, 2019.

signaturesignature

Clock3 mths