Forum / Remote Desktop Manager - PowerShell Repository

Remove empty folders

  • Create an Issue
  • Cancel

Hi.

Can I find all empty folders(Sessions) and remove them?

Name are unique per Grope.

If Grope is only listed ones then Names is empty.

What next?

Clock2 yrs

Is it to do a cleanup?

Regards

David Hervieux

signaturesignature

Clock2 yrs

Hello,

It is possible to find and delete empty folders in your data source using this script. The folder name will be in the Group property of each entry if the folder isn't empty.

$folders = Get-RDMSession | where {$_.ConnectionType -eq "Group"}
foreach ($folder in $folders)
{
$foldername = $folder.Name
$session = Get-RDMSession | where {$_.Group -like "*$foldername" -or $_.Group -like "*$foldername\*"}
if ($session.count -eq 1)
{
Remove-RDMSession $session -Refresh -Force
Write-Host "Folder $foldername deleted!"
}
}

Best regards,



Érica Poirier

signaturesignature

Clock2 yrs

Erica Poirier wrote:

Hello,

It is possible to find and delete empty folders in your data source using this script. The folder name will be in the Group property of each entry if the folder isn't empty.

$folders = Get-RDMSession | where {$_.ConnectionType -eq "Group"}
foreach ($folder in $folders)
{
$foldername = $folder.Name
$session = Get-RDMSession | where {$_.Group -like "*$foldername" -or $_.Group -like "*$foldername\*"}
if ($session.count -eq 1)
{
Remove-RDMSession $session -Refresh -Force
Write-Host "Folder $foldername deleted!"
}
}

Best regards,

Clock2 yrs

Thanks

Work grade

Clock2 yrs