Hi,
we would like to create a script that automatically links a list of entries to a specific folder.
This should also work when an entry is checked out.
We tried to edit the "Group" attribute of the entry, e.g.:
Import-Module "${env:ProgramFiles(x86)}\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShellModule.psd1"
Update-RDMUI
$session1 = Get-RDMSession -Name "Name1"
$session2 = Get-RDMSession -Name "Name2"
$session.Group = $session2.Group
Set-RDMSession -Session $session1 -Refresh
Session2 is linked to a group of folders and we thought that Session1 will be linked to the same folders after executing the script.
After execution, there seems to be a hangup. PowerShell loads forever without outputting any result or debug information. And Session1 is then also not linked at the same folders as Session2.
Are we missing something or is there a better way to create shortcuts via PowerShell?
BR
Hello,
What RDM version are you using?
Have you made a typo in the script you have provided or if it's just a copy-paste problem? The following line is missing a '1' for the variable name.
$session1.Group = $session2.Group
I did the following test and it's working properly.
$session1 = Get-RDMSession -Name LocalHost $session2 = Get-RDMSession -Name LocalHost2 $session1.Group = $session2.Group Set-RDMSession $session1 -Refresh
Let me know if that helps.
Best regards,
Érica Poirier
Hi Erica,
that was just a typo witihin the forum post. The real script has different session names but the same for editing and saving the session.
Is it possible that it is not working cause the entry is checked out?
BR
Hello,
Thank you for your feedback.
Indeed, if the entry is checked out, no ones can edit the entry even an administrator. Was it the problem when you tried to run the script?
Best regards,
Érica Poirier
Hi,
yes, that was the problem we wanted to solve.
We have a couple of entries (VMs) that should be linked to a customer folder - if the customer can be supported from this vm.
And we also use the check-out feature to mark a VM as "in use".
It is possible to link the entries via gui, even if they are checked out (as an admin). But only one after another.
So it would be nice to have a script that gets the job done.
But if I understand it correctly, there is no way to link checked out entries via PowerShell?!
Best Regards
Hello,
Thank you for your feedback.
How do you link the entry to another folder in the GUI? Are you creating a shortcut of the entry?
I did few other tests and I can update the Group property using PowerShell even if the 3 test entries are checked out.
When loading the RDM PowerShell module, it will use the default data source. Is it possible that the data source used in PowerShell isn't connected with an administrator account?
Best regards,
Érica Poirier
Hello Erica,
Thanks for your fast response.
Yes, within the GUI we just create a shourtcut of the entry.
You are right, the problem was that the admin account was not used within PowerShell.
However, when I try to save the entry using "Set-RDMSession $session1 -Refresh”, I get the following error message:
Set-RDMSession : Für die Verbindung wurde eine ungültige Gruppe angegeben.
In Zeile:1 Zeichen:1
+ Set-RDMSession -Session $session3 -Refresh
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-RDMSession], Exception
+ FullyQualifiedErrorId : 0,RemoteDesktopManager.PowerShellModule.SetRDMSessionCommand
Translation of: "Für die Verbindung wurde eine ungültige Gruppe angegeben.: An invalid group was specified for the connection
Is it possible that this error appears cause the entry has some shortcuts that were created within the GUI?
What's interesting is that the folders appear twice when printing the Group property, e.g.:
IT\Remote Access\VMs\IT;ST\VMs IT\Remote Access\VMs\IT;ST\VMs
-> I created the entry in the folder "IT\Remote Access\VMs\IT" and linked it to "ST\VMs".
Is this the expected behaviour (that the folders appears twice when printing the Group property)?
Best Regards
Hello,
Thank you for your feedback.
The Group property should have only one line. And each folder where the entry is visible are separated with a semi-colon.
I would recommend to verify if the folder exists in the Group property before trying to add it at the end of the property.
Let me know if that helps.
Best regards,
Érica Poirier
Hi Erica,
I tried the following:
folder1;folder2
folder1;folder2
I am not sure if that is the normal behaviour for shortcuts or a bug?
BR
Hello,
Thank you for your swift reply.
No it's not the default behaviour.
Is the script you are using the same as the one posted in that thread? If not, could you please share it so I could try it in our environment?
We could also have a remote session to troubleshoot this problem. Please send an email to ticket@devolutions.net and add a reference to that thread.
Best regards,
Érica Poirier
Hi Erica,
thanks for your help. I will be on vacation for the next two weeks.
After my return, I will investigate that in detail and post an update.
Best Regards
Hello,
Thank you for your feedback and I will wait for your return in two weeks.
Have a great vacation!
Best regards,
Érica Poirier
Hi Erica,
I have tested that again and after creating a shortcut within the GUI, the Group property indeed has two identical lines:
Before creating the shortcut:
After creating the shortcut:
Could that be a bug?
RDM: 2020.3.26 Enterprise
Datasource: MySQL
BR
Hello,
Thank you for your feedback.
This is a normal behaviour as the RDM PowerShell module behaves like the navigation pane in RDM. If an entry has a shortcut somewhere in the tree structure, it will appear in both places. With the Get-RDMSession cmdlet, it will return all entries no matter if it's a shortcut or the original entry.
If you check the number of connection objects in the $testconnection variable, you should have an array of two connections. In fact, if you want to update the information on this entry, you should do it on the first item of the array like this:
$testconnection = Get-RDMSession -Name "TestSession"
$otherconnection = Get-RDMSession -Name LocalHost2
$testconnection[0].Group = $otherconnection.Group
Set-RDMSession $testconnection[0] -Refresh
Let me know if you have further questions related to shorcuts.
Best regards,
Érica Poirier
Hi Erica,
thank you very much for your feedback.
I tried it again, but Set-RDMSession always gives me the following error:
The only thing that I noticed is that the line break is missing after setting the Group property using PowerShell.
BR
Hello,
Thank you for your feedback.
I'm sorry that I've made a typo in the code in my previous post and that's why you get this error. Here is the correct command you should use.
Set-RDMSession $testconnection[0] -Refresh
Let me know if that works.
Best regards,
Érica Poirier
Hi Erica,
Thank you very much for your help.
I did some further tests and the following change did the trick:
Instead of:
$testconnection[0].Group = $otherconnection.Group
It is of course necessary to select the first element of the array for $otherconnection as well:
$testconnection[0].Group = $otherconnection[0].Group
BR
Hello,
Thank you for your feedback and glad that it works now.
You're right if the $otherconnection is an array, you need to select the appropriate array element.
Best regards,
Érica Poirier