When I export a file it nicely is shown in the file organizer where it is exported to.
There is a [ProjectWiseDocument]$doc0PwObject.CheckedOutLocalFileName, but this remains empty
How can I find the location to which the file was exported to?
Thanks in advance.
Not sure where local document organizer gets the info from but the only way i'm finding to get it is via the document's audit trail.
(side note: CheckedOutLocalFileName only gets populated when checking out the file with CheckOut-PWDocument. Using Get-PWDocumentsBySearch, including with the -Slow option, will not populate that field even if you already have the file checked out.)
Using Get-PWDocumentAuditTrailRecords I was able to retrieve the info. This may be slow if your documents have a lot of audit trail records.
$atrails = Get-PWDocumentAuditTrailRecords -FolderPath 'pw\path' -DocumentName 'TestFile.txt'
$expRec = @($atrails | Where Action -eq 'Document Export' | Sort Action_Time -Descending)
$expRec | Select Action_Time,Action,Item_Name,Text_Param
($Node,$Path) = $expRec.Text_Param.Split('|')
The line where i put @() around the statements is a trick to force the results of the commands into an array. The  gets the first element of the array (which because we sorted by the action time will be the last export that occurred)
The Text_Param propert of the audit trail contains the path info. It's in the form of the node where it was exported, vertical bar, path it was exported to.
You should verify the file is still actually exported before using this, if the file was freed or imported since the export the above will still find the info for the last time the file was exported even though it's no longer valid.
Thanks for figuring out! I can surely use it. A pity that 'CheckedOutLocalFileName' is not in use, that would be a very clean way to expose that kind of info.
I am curious, would it be also helpful for others if the path info is accessible by a cmdlet? Is a feature request for getting this info a possible benefit for more programmers?
For exported files I can see this, for checked out files I think the reason they don't populate it is because it depends on the user. I don't think the information is stored in the database (the audit trail doesn't get that info on checkout), i think it's stored in the user's local document organizer only.
You can calculate it, but i suspect it might be slow, by taking the user that has it checked out and getting their working directory, then appending the documen's folder id, looking up the folder properties and then:
$userWkDir = Join-Path -Path $WorkDir -ChildPath $Folder.Code
$checkout = Join-Path -Path $userWkDir -ChildPath $doc.FileName
I got curious how hard this would be to produce. Here's what I came up with (this is for check outs, not exports)
$coDoc = Get-PWDocumentsBySearch # options to find checked out document
$fcode = (Get-PWFolders -FolderID $coDoc.ProjectID -JustOne).Code
$workDir = (Get-PWUserSettingByUser -InputUser $coDoc.DocumentOutTo -SettingName WorkDir_WhenUsingPWExplorer).UserSettingValue
$userWkDir = Join-Path -Path $workDir -ChildPath $fcode
$coLocation = Join-Path -Path $userWkDir -ChildPath $coDoc.FileName
That does no error checking and assumes the $coDoc is actually a checked out document (and only one i think, not sure it works with a list of them)
Document checkout info doesn't include the node the document was checked out to. I know it's available because you can turn it on as a view column. With this added in you could construct a UNC to an admin share on that computer.
Just replace c: in the path with