When running Get-PWDocumentsBySearchWithReturnColumns, it stops with the error "Illegal characters in path", but the error does not contain the path or the characters. Does someone have advice on how to figure out which folder is the culprit?
Have you tried adding -Verbose or -Debug to the parameters?
It would be helpful if you posted your script, or enough of it so that the context of the use of the Cmdlet is available to consider what the problem might be as well as a screen shot of the exact error messages, etc.
A common "problem" is that PowerShell interprets double and single quote characters in a way that you may not be expecting. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
Here is the script that causes the error:
$Folders = (Get-PWDocumentsBySearchWithReturnColumns -FileUpdatedAfter 2016-01-01 -FileUpdatedBefore 2017-01-01 -Verbose).FullPath
We are looking at some older data and the folder structure that goes with it. I want to take the folder names and run some analysis on it, but I can't get past this first step without the error.
Here is what is returned:
VERBOSE: Found 126716 documents
Get-PWDocumentsBySearchWithReturnColumns : Illegal characters in path.At line:1 char:13+ $Folders = (Get-PWDocumentsBySearchWithReturnColumns -ErrorAction Sil ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-PWDocumentsBySearchWithReturnColumns], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,PWPS_DAB.GetPWDocumentsBySearchWithReturnColumns
OK, I can reproduce the error and it is what it says. Your data has one or more characters in the path that are not valid in Windows. You can in fact use these characters "*."/\" in ProjectWise to name a folder or a document (file names still have to be valid), but when they are converted into paths, they generate an error.
Here's how I reproduced the error:
This looks like this in ProjectWise Explorer:
Here's what I ran in PowerShell:
> $Folders = (Get-PWDocumentsBySearchWithReturnColumns -FileUpdatedAfter 2016-01-01 -FileUpdatedBefore 2021-01-01 -Verbose).FullPath
VERBOSE: Found 742 documents
Get-PWDocumentsBySearchWithReturnColumns : Illegal characters in path.
At line:1 char:13
+ $Folders = (Get-PWDocumentsBySearchWithReturnColumns -FileUpdatedAfte ...
+ CategoryInfo : NotSpecified: (:) [Get-PWDocumentsBySearchWithReturnColumns], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,PWPS_DAB.GetPWDocumentsBySearchWithReturnColumns
I don't know if this will be "fixed" or not, but you should be able to find the invalid folder names by using the ProjectWise Explorer menu command "Folder -> Export..." and then selecting the "Send to Folder" option.
Here's what the results of that look like for my test folder:
You might try this against some of the folder trees in your datasource to see if you can locate the folders with illegal characters in their names.
That method does work, but depending on the number of folders/files it can take quite a long time to find the one with the illegal characters. It would be great if the powershell script could simply return that information.
Look for a change in behavior in the next release of PWPS_DAB for Get-PWDocumentsBySearchWithReturnColumns. Instead of throwing an exception, it will report the illegal character message if you use the -Verbose switch. With or without the -Verbose switch, the path is added to the document object with the illegal characters.
Looks like this:
And the output from $Folders looks like this:
That will work, thanks!
Change in implementation.
Get-PWDocumentsBySearchWithReturnColumns will report invalid characters in folder paths as warnings regardless if -Verbose is specified or not, but you now have to specify the -PopulatePath switch. You can capture the warnings to a variable by using the -WarningVariable parameter.
This behavior is in PWPS_DAB version 126.96.36.199.