Forum / Remote Desktop Manager - PowerShell Repository

Repository rename

  • Create an Issue
  • Cancel

Hello,

I have many repository ( one for every clients) with many folder :
image

I have to rename for each repository a name of a subfolder.

Can you help me to make my powershell script ?

Thanks

Clock5 mths

Hello,

It seems that your image doesn't work. Is it possible to post it again?

Best regards,



Jeff Dagenais

Happy Holiday Season!
Although our various support queues will be monitored during the coming holiday season, Devolutions' offices will be closed from December 24th, 2019, to January 1, 2020, inclusively.

signaturesignature

Clock5 mths

Up ;-)

Clock5 mths


Hello,

In fact, when you want to rename a folder, you also need to update the information in the Group property of the folder itself and all its child items.

Here is a sample you can use to rename a folder in all vaults no matter if it's a top folder or a sub folder.


$oldFolderName = Read-Host "Enter the name of the folder you want to rename "
$newFolderName = Read-Host "Enter the new folder name "

$repos = Get-RDMRepository

foreach ($repo in $repos)
{
Set-RDMCurrentRepository $repo -ErrorAction SilentlyContinue
Update-RDMUI

try
{
$folders = Get-RDMSession -Name $oldFolderName -ErrorAction SilentlyContinue | where {$_.ConnectionType -eq "Group"}
foreach ($folder in $folders)
{
### Update the folder name
[string]$group = $folder.Group
$group = $group -Replace $oldFolderName,$newFolderName
$folder.Group = $group
$folder.Name = $newFolderName
Set-RDMSession $folder -Refresh

### Update folder name of each child items including subfolders
$sessions = get-rdmsession | where {$_.Group -like "*$oldFolderName*"}
foreach ($session in $sessions)
{
[string]$group = $session.Group
$group = $group -Replace $oldFolderName,$newFolderName
$session.Group = $group
Set-RDMSession $session -Refresh
}
}
}
catch
{

}
}

Best regards,



Érica Poirier

Happy Holiday Season!
Although our various support queues will be monitored during the coming holiday season, Devolutions' offices will be closed from December 24th, 2019, to January 1, 2020, inclusively.

signaturesignature

Clock5 mths