Currently Get-PWApplications returns a weird object where Keys is an array of the application ids and Values is an array of application names.
Would it be possible to have this return a custom obect with properties AppID and AppName (or just ID and Name)?
As it is if I want to find the application id for an app I have to do some weird programming. If it returned a custom object I can use Where clauses with it.
I'd like to be able to do:
Get-PWApplications | Where AppName -like "Microsoft*"
It appears the list is an alphabetized array and the index and ID are not the same. I had to use
$apps = get-pwapplications$apps.indexof('Autocad')
and I am not getting the correct ID. I get 2 and it should be 6
From Get-PWDocumentsBySearch -FolderPath $docPath -Filename $docName -getattributes
OldVersion : WorkflowId : 10StateId : 1ApplicationId : 6ApplicationName : AutocadCheckedOutLocalFileName : CopiedOutLocalFileName : IsAbstract : False
And when I run this, I get 2:
2
The code Kevin provided didn't work for me. So how would I find the ID of an application?
It looks like Get-PWApplications has been changed to return an array of strings now. It doesn't provide the index. The list is returned sorted so the index in the array is not the application id.
I dug through most of the cmdlets that work with applications and it looks like they all will take the string name, what are you doing that requires the application id?
We will be converting files from DGN to DWG and then replacing the DGN file with the DWG in ProjectWise to keep the record data as well as for to other reasons beyond my control. So I will need to change the Program Association while replacing the file and per this thread from Jan 2021, I see this comment (from some guy named Kevin van Haaren if he is to be trusted... :-) ):
Next update the ApplicationID on each document (don't update the ApplicationName!) you can get a list of application IDs with get-pwapplications
foreach ($doc in $doclist) { $doc.ApplicationID = new_id }
I have 11 datasources and could always just build a table instead of getting the ID programmatically if needed. I can try setting the application name instead and see what happens, but won't get to it for a day or two..
I wouldn't trust that guy, sounds like a flake.
Bentley added a new cmdlet Set-PWDocumentApplication that will set the application using the Name instead of the ID. It also has the benefit of being able to set the application on both document versions and documents in final status (without removing final status and reapplying it).
It'll also accept an array of documents so you don't need a foreach loop either.
$docList = Get-PWDocumentsBySearchExtended -FolderPath 'path\to\project' -DocumentName '%.dwg' -Application "MicroStation" $docList | Set-PWApplication -Application "AutoCAD" -ChangeVersionApplications -ChangeFinalStatusApplications