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

Clock8 mths

Hello,

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

Best regards,



Jeff Dagenais
signaturesignature

Clock8 mths

Up ;-)

Clock8 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

signaturesignature

Clock7 mths