Using ISHRemote how can I exclude folders based on their names?

Hi,

I am trying to get a count of topics within a root folder but excluding subfolders with certain words in their names.

I have tried the following but it is still returning folders named 'retired' and 'Archived'

$ishFolders = Get-IshFolder -IshSession $ishSession -FolderPath $ishFolder -FolderTypeFilter @("ISHModule") -Recurse |
Where-Object -Property IshFolderType -EQ -Value ISHModule |
Where-Object {
$_fname -notlike "Retire" -and
$_fname -notlike "Test" -and
$_fname -notlike "Admin" -and
$_fname -notlike "Archive" -and
$_fname -notlike "do not use"
}

foreach ($ishFolder in $ishFolders)
{
Write-Host $ishFolder.fname
foreach ($ishObject in (Get-IshFolderContent -IshSession $ishSession -IshFolder $ishFolder -MetadataFilter $metadataFilter | Get-IshDocumentObj))
{
Write-Host $ishObject.IshRef
++$xmlTopicCount
}
}
Write-Host ("Topic Count["+$xmlTopicCount+"]")

What am I doing wrong?

Any advice appreciated,

Regards,

Ann

emoji
Parents
  • Automation can be beautiful and really speed up some manual process like counting. However, a script can do things 1000s of times faster than a user clicking around, hence we should all be on the lookout that a script can really bring a system to its knees!

    Regarding your first part, I rewrote using -BaseFolder EditorTemplate as a sample, because every system has that and can experiment with this code.. Compared to your sample

    1. Line 2 filter on IShFolderType is the same as the Line 1 -FolderTypeFilter, so superfluous.
    2. The loop operator in PowerShell, so inside your Where-Object cmdlet is $_ ... you want to address properties of that loop object, so you need "." (dot)
    3. In turn, Colin earlier is right that you are not using the operator -notlike correctly, it is missing the wildcards "*" (asterix)

    $ishFolders = Get-IshFolder -BaseFolder EditorTemplate -FolderTypeFilter @("ISHModule") -Recurse |
    Where-Object {
        $_.fname -notlike "Retire" -and
        $_.fname -notlike "Test" -and
        $_.fname -notlike "Admin" -and
        $_.fname -notlike "Archive" -and
        $_.fname -notlike "do not use" -and 
        $_.fname -notlike "*Topics" 
    }

    Regarding part 2, you are counting logical objects (IshRef) property, then the Get-IshDocumentObj in the foreach statement is superfluous and causes a lot of API/Database traffic. 

    If Get-IshDocumentObj is an attempt to get all versions and languages, it is missing parameters. Currently it only retrieves all languages from the Latest version.

    Best wishes,
    Dave

    emoji
Reply
  • Automation can be beautiful and really speed up some manual process like counting. However, a script can do things 1000s of times faster than a user clicking around, hence we should all be on the lookout that a script can really bring a system to its knees!

    Regarding your first part, I rewrote using -BaseFolder EditorTemplate as a sample, because every system has that and can experiment with this code.. Compared to your sample

    1. Line 2 filter on IShFolderType is the same as the Line 1 -FolderTypeFilter, so superfluous.
    2. The loop operator in PowerShell, so inside your Where-Object cmdlet is $_ ... you want to address properties of that loop object, so you need "." (dot)
    3. In turn, Colin earlier is right that you are not using the operator -notlike correctly, it is missing the wildcards "*" (asterix)

    $ishFolders = Get-IshFolder -BaseFolder EditorTemplate -FolderTypeFilter @("ISHModule") -Recurse |
    Where-Object {
        $_.fname -notlike "Retire" -and
        $_.fname -notlike "Test" -and
        $_.fname -notlike "Admin" -and
        $_.fname -notlike "Archive" -and
        $_.fname -notlike "do not use" -and 
        $_.fname -notlike "*Topics" 
    }

    Regarding part 2, you are counting logical objects (IshRef) property, then the Get-IshDocumentObj in the foreach statement is superfluous and causes a lot of API/Database traffic. 

    If Get-IshDocumentObj is an attempt to get all versions and languages, it is missing parameters. Currently it only retrieves all languages from the Latest version.

    Best wishes,
    Dave

    emoji
Children