#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

How To: Update Document Attributes Using PowerShell

Be sure to check out my Scripting4Crypto initiative. It’s a fun way to get into using cryptocurrencies all while getting your PowerShell needs met.

Recently, I have had a few requests for assistance with updating ProjectWise Document attributes using PowerShell.  So, I am going to step through the process in this post. Hopefully, you will find it useful.

We will be using the following cmdlets to accomplish this task. All of the ProjectWise related cmdlets are available using the PWPS_DAB module. Take a look at the help for each of the cmdlets to become familiar with their functionality, available parameters, etc.

  • Get-PWDocumentsBySearch
  • Update-PWDocumentAttributes

You will need to be logged into a ProjectWise datasource with the appropriate permissions to make updates to the document attribute values.

Lets take a look a the parameters for the Update-PWDocumentAttributes cmdlet. Within PowerShell, I typed in Get-Help Update-PWDocumentAttributes -Full.  This will return all of the help information available for this cmdlet.


Above, you’ll see that the Update-PWDocumentAttributes cmdlet has three parameters available.

  1. InputDocuments parameter which accepts one or more ProjectWise Document Objects.  These can be passed via the pipeline if desired. In this example, we will not pass the document objects via the pipeline. We are going to set different attribute values for each document.
  2. Attributes parameter accepts a hash table of attribute and attribute value pairs.
    1. Example:  @{ Milestone = ’30’ }
  3. ReturnBoolean parameter when included, will return a True if the document attributes are updated successfully, otherwise False.

NOTE: The document object will be returned if the ReturnBoolean parameter is not included.

The following image shows my ProjectWise Environment named PowerShell. This Environment contains four attributes. One is for the title (POWERSHELL), and the other three can be updated for each document, Discipline, Milestone, and Percent Complete.


The following is the folder within ProjectWise Explorer which contains the four documents we will be updating. Each document does not have any attribute values set for Discipline, Milestone, and Percent Complete.

PW - PW Folder and Documents

First, we will use the Get-PWDocumentsBySearch to get the ProjectWise document objects we want to update. The following returns four ProjectWise document objects.

# ProjectWise Folder containing the documents to update.
$PWFolder = 'PowerShell\Update Documents'
# Obtain all documents located in the folder.
$PWDocuments = Get-PWDocumentsBySearch -FolderPath $PWFolder -Verbose

If I do a $PWDocuments.Count within PowerShell, you’ll see that it returns 4. Or I can return the names of the four documents using $PWDocuments.Name.

PS D:\> $PWDocuments.Count

PS D:\> $PWDocuments.Name

Now, that we have our four documents to update, we will loop through each and update the three available document attributes.

<# Index to track which document we are processing.
    Because we are using a foreach loop, I need an index to track the 
    current document being processed.  #>
$Index = 0
<# Loop through each of the ProjectWise Documents 
    and update the document attributes.  #>
foreach ($PWDocument in $PWDocuments) {
    <# Specify attribute values
        The Discipline attribute value will be the same for all documents. #>
    $Attributes = @{
        Discipline = 'RoadDesign'

    <# The MileStone and TB_PERCENT_COMPLETE attribute values will
        be the same for first and third documents and 
        second and fourth documents. #>
    if($Index -eq 0 -or $Index -eq 2) {
        $Attributes.MileStone = 'Open'
        $Attributes.TB_PERCENT_COMPLETE = '20'
    } else {
        $Attributes.MileStone = 'ExportFromProjectWise'
        $Attributes.TB_PERCENT_COMPLETE = '90'

    <# By returning the boolean, we can use a simple if else statement
        to write back to the console whether the process was successful
        or not. #>
    if( Update-PWDocumentAttributes -InputDocuments $PWDocument -Attributes $Attributes -ReturnBoolean ) {
        Write-Verbose -Message "Successfully updated the document attributes for '$($PWDocument.Name)'." -Verbose
    } else {
        # Could return an error or warning here. Up to you.
        Write-Warning -Message "Failed to update the document attributes for '$($PWDocument.Name)'."

    # Increment the index value by one.

The following shows the results of the running the PowerShell script.

PowerShell Results

In the image below, you can see that the four documents attributes were successfully updated.

PW - Updated Attributes

The following is a link to the full PowerShell script.


Experiment with it and have fun.

Hopefully, you find this useful. Please let me know if you have any questions or comments.  If you like this post, please click the Like button at the bottom of the page.

2 thoughts on “How To: Update Document Attributes Using PowerShell”

    1. The following should return the ColumnName and corresponding Label for each attribute within the provided Environment.

      $EnvironmentName = ‘Simple’
      $pwenv = Export-PWEnvironments -Environments $EnvironmentName
      $interface = $pwenv | Where TableName -eq ‘Interfaces’
      $interface | Select ColumnName, Label


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.