Multiple Folders in New-PWScanForReferences -Priority

I am trying to use the New-PWScanForReferences  cmdlet and have it scan multiple Folders to find the references.  The executable wants these separated with a semicolon but this doesn't seem to work.  Per the executable's help, I would also proceed the folder with 'r:' for recursive, but this also does not work and appears to need the -RecursePriority.  It seems a trailing backslash is needed even though the help for the executable does not have this requirement.

From the executable's help:

For example, the combination of:
-masterfolders "Top level folder 3" -masterfolders "Top level folder 1;Top level folder 2"
is equivalent to:
-masterfolders "Top level folder 3;Top level folder 1;Top level folder 2"

My code is:

$myPriority = 'Folder 1\subfolder\;Folder 2\;Folder 3\'

$NewScanRef = @{
DataSourceName = 'myDatasource';
UserName = 'myUserName';
Password = 'mypassword;
ScanMode = 'references;linksets';
MasterDocuments = '{' + $myDocumentGUID + '}';
Priority = $myPriority;
#Proximity = 'r:1';
Order = 'priority;proximity';
#Applications = '';
LogFilePath = $myLogpath ;
New-PWScanForReferences @NewScanRef -RecurseMasterFolders -RecursePriority

I have also tried using 

$myPriority = @("Folder 1\subfolder\","Folder 2\","Folder 3\")


$myPriority = "Folder 1\subfolder\","Folder 2\","Folder 3\"

With no success.  What am I missing?

  • I don't think -MasterDocuments accepts a GUID. I think it needs to be a filename or file pattern.

    i would not do both priority and proximity especially since you don't seem to specify anything for  the -Proximity parameter.

    Finally, the New-PWScanForReferences must be run from 32-bit powershell, are you doing that?


  • Yes, I am using the 32 -bit PowerShell.

    Everything works until I want to scan multiple folders for possible references.  I need to figure out how to scan multiple folders in the priority.  Ideally I would also scan multiple files with the same call, and that would be my next step once I get this working.  I suspect it should be the same for the files as it is for the folders.  Per the executable's help, I should be able to pass a list of files as well, and should be able to use the GUID for that, by enclosing each in {}.

    The File GUID works and was better than using the name for a few reasons in this case.

    I can drop the proximity setting if I get this working but having it set this way has not stpped execution if there is only 1 folder passed to priority.  There is a problem with Proximity in that the executable allows the number to be more than 0 or 1 but the cmdlet limits it to 0 or 1.  On the command line I was able to set a higher number, so it started scanning priority 4 folders above the file's folder.  But I am fine dropping priority as long as I can search multiple folders for proximity.

  • What version of ProjectWise Explorer do you have installed on the machine you are running PowerShell on?


    Mark Weisman | Bentley Systems

  • As far as the parameter to New-PWScanForRerences go, there should be nothing to prevent you from using GUIDS.  Also there should be nothing from using multiple folders.  We will investigate.  

    Assuming you have the latest version of PWPS_DAB installed, you may remove the validation of the Proximity parameter by placing a # sign in at the beginning of line 276 in \Program Files\WindowsPowerShell\Modules\pwps_dab\\HelperFunctions.psm1.  Let us know if that helps.


    Mark Weisman | Bentley Systems

  • In the help presented here:

    Folder lists 

    - begin with the top level folder

    - are separated by backslashes ie \

    0 Do not end with a trailing backslash

    Your first attempt at a folder list is

    $myPriority = 'Folder 1\subfolder\;Folder 2\;Folder 3\'

    Is Folder 1 the top level folder?

    You should not have the trailing backslash.

    It looks like the RecursePriority switch just prefixes the path with r:

    That's all good if you just have one path but I'm not sure what it would mean if you had multiple paths separated by semicolons.  I'd try the search without the RecursePriority switch first.  Then I would put the r: in the appropriate place(s) rather than use the switch.

    Scanrefs has always been a bit of an art.  If you can come up with a working  OS scanref command line does not translate into a PowerShell command please post it.

    Hope this helps,

    Mark Weisman | Bentley Systems