The Get-VaultFile and Get-VaultFiles commandlets are convenient to use but they have a lot of overhead when creating the file objects, which makes them rather slow when used on a huge dataset. They also have some other restrictions. For example when it comes to searching for dates.
On those cases it is possible to use the Vault API directly to search for files. You have to know that there are separate search functions for folder, file, link, item and custom entities. Though they all work pretty much the same.
The "VaultSearch.zip" in the attachments contains a module with some sample functions to simplify this procedure a little bit. We had situations when the Find-VaultFiles commandlet was very slow. If this is the case you have to take the code from it and write it directly into your job. It is some weird side effect when the search function was called within a function. usually it should take just a couple of seconds for multiple thousand files.
- Define a search condition using the New-SearchCondition function and specify following parameters:
- PropertyName: The name of the property to search for
- SearchOperator: The operator that is used for the search e.g. equal or contains
- SearchRuleType: Must contain or may contain
- SearchText: The text to search in the specified property
- Search for files using Find-VaultFiles:
- RootFolderPath: Specify the root folder where the search should begin
- SearchConditions: Pass the result from New-SearchCondition that you executed before
- RecurseFolders: Specify $true for searching folders recursively
- LatestFilesOnly: Gets only the latest files
- Optionally you can also sort the results using New-SearchSort:
- PropertyName: The name of the property
- SortAsc: Define $true or $false to sort ascending.
Import-Module powerVault Open-VaultConnection $searchcondition = New-SearchCondition -PropertyName "Name" -searchOperator Contains -searchRuleType Must -searchText "Drawing" $result = Find-VaultFiles -RootFolderPath "$" -SearchConditions $searchcondition