Forum / Remote Desktop Manager - PowerShell Repository

Is there a way to work with RDM folders in PowerShell?

  • Create an Issue
  • Cancel

Is there a way to work with RDM folders in PowerShell?
- I want to be able to create folders and sub folders.
- Check if a folder exists.

The way I do it today is not easy and do not work on sub folders and I can’t check if the folder exists.
$session = New-RDMSession -Type "Group" -Name $RDMGroupe
$session.Group = $RDMGroupe
Set-RDMSession $session

Clock7 mths

Hello,

To check if a parent folder exist, you could use the try-catch command like the following :

try
{
# Check if folder exist

$exist = Get-RDMSession -Name $parent -ErrorAction Stop
}
catch
{
# Folder doesn't exist
}


And to create a sub folder, you have to specify the full path including the new sub folder name for the -Group parameter like the following :
$session = New-RDMSession -Name "FolderB" -Type "Group" -Group "FolderA\FolderB" -SetSession

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

Thanks,
I can now check if a folder exists.
But I do not get to create a sub folder, I get the error:
New-RDMSession : Object reference not set to an instance of an object.
At line:1 char:12
+ $session = New-RDMSession -Name "FolderB" -Type "Group" -Group "Folde ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (smile [New-RDMSession], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,RemoteDesktopManager.PowerShellModule.NewRDMSessionCommand

Clock7 mths

Hello,

What RDM version are you using?

What data source type are you connected to? If it is Devolutions Password Server, what version are you using?

With that information, I will try to reproduce your issue.

For your information, I am moving this thread in the PowerShell section.

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

I am Running version 2019.1.17.0 Data source Microsoft SQL Server.

Clock7 mths

Hello,

And just to be sure sure, as I cannot see the parent folder on that error message, could you please confirm that the folder exist before creating a sub folder?

New-RDMSession : Object reference not set to an instance of an object.
At line:1 char:12
+ $session = New-RDMSession -Name "FolderB" -Type "Group" -Group "Folde ...

If you create the parent folder in the same script, you need to update the cache file using the Update-RDMUI cmdlet before creating entries or sub folders.

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

Yes, the parent folder eksist.

Clock7 mths

Hello,

Could you please try the latest RDM beta version 2019.1.18? You can download it here :
https://remotedesktopmanager.com/home/download#Beta

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

I have now installed version 2019.1.18, I am getting the same error.

image

Clock7 mths

Hello,

I have finally been able to reproduce your issue and a ticket has been sent to our engineering department. For your information, the internal ticket number is RDMW-2685. Once a fix will be available, we will let you know.

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

Hello,

The issue has been resolved and the fix is available in RDM version 2019.1.21 that has been released yesterday.

Could you please give it a try and let me know if this is now working?

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

Hello,
Now the folder is created but it is in the wrong place and has a different picture.

image

image

Clock7 mths

Hello,

From the commands I see in your screen shot, the FolderE is already set to be under FolderA on the New-RDMSession line. And with the -SetSession switch, it should already be saved in the data source. If you execute the Get-RDMSession cmdlet just after the New-RDMSession, is the folder now in the right place?

Just after the creation of the folder with New-RDMSession, you have modified the group with the $RDMGroupe variable. What is the content of that variable? Is it empty or contains something different than "FolderA\FolderE"?

Best regards,



Érica Poirier

signaturesignature

Clock7 mths

Tanks, that solved it.

Clock7 mths

Hello,

Thank you for your feedback and glad that the issue has been resolved.

Best regards,



Érica Poirier

signaturesignature

Clock7 mths