#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

HowTo: Use Range to Submit Renditions 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.

In this post, I want to share how I used a range to select a subset of ProjectWise document objects from a collection to be submitted for renditioning using PowerShell. Keep in mind the following is the solution I came up with. If you have other ideas, suggestions, or recommendations that would make this better, easier, etc., please share.

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

  • Get-PWFolders
  • Add-PWSavedSearch
  • Get-PWDocumentsBySearch
  • New-PWRenditionRequest

We will also be using the C# Math assembly to take advantage of the Ceiling method. The following is a link to get more information: C# MATH Assembly

Parameters we are going to use.

    # Specifies parent Work Area.
    [string] $WorkAreaName = 'BSI900 - Adelaide Tower',
    # Specifies Work Area subfolder to search in.
    [string] $PWFolderPath = "$WorkAreaName\01-WIP",
    # Specifies the name of saved search.
    [string] $SavedSearchName = 'BSI900 - PlotSet',
    # Search criteria for the saved search. We will be returning DGN and DWG files.
    [string] $SearchCriteria = '%.d%',
    # Rendition profile to be used. 
    [string] $RenditionProfile = 'PDF to Renditions Folder',
    # Specifies the number of document to submit in each rendtion request.
    [int] $NumberOfDocsPerSubmission = 5

First, we need to select the documents we want to submit for renditioning. To accomplish this we are going to create a new saved search and use it with the Get-PWDocumentsBySearch to obtain the document objects.

<# Using splat for readability.
    Splat contains the parameter and value pairs for the Add-PWSavedSearch cmdlet. #>
$Splat_SavedSearch = @{
    OwnerProject = (Get-PWFolders -FolderPath $WorkAreaName -JustOne)
    SearchName = $SavedSearchName
    SearchFolder = $PWFolderPath
    DocumentName = $SearchCriteria
# Create new saved search within the specified work area.
Add-PWSavedSearch @Splat_SavedSearch -SearchSubFolders -OriginalsOnly -Verbose

The following shows the verbose output for the Add-PWSavedSearch.


Next we will use the new saved search to get the document objects which will be submitted for renditioning.

# Get document objects to submit for renditioning.
$pwDocs = Get-PWDocumentsBySearch -SearchName $SavedSearchName -GetAttributes

The following shows the number of document objects returned.


The following shows the list of documents within ProjectWise Explorer.


Now we need to determine the number of iterations (or the number of times we will need to loop through the ProjectWise Document objects) to be used. We will use the Ceiling method of the Math assembly to calculate the number of iterations. This is done by dividing the number of documents by the number of documents per submission.

Math.Ceiling – Returns the smallest integral value that is greater than or equal to the specified (decimal or float) number. https://docs.microsoft.com/en-us/dotnet/api/system.math.ceiling?view=netframework-4.8

# Determine the number of iterations.
$Iterations = [Math]::Ceiling($pwDocs.Count/$NumberOfDocsPerSubmission)

The following shows the number of iterations calculated.


Lets use a for loop to cycle through the iterations. We will select five documents at a time and submit them for renditioning. I am outputting information to the console using the Write-Host cmdlet. I typically would not do this, however it is for demonstration purposes only.

The following shows the Renditioning profiles within the ProjectWise Administrator.


You can see that I calculate the minimum range value by multiplying the index value by the number of docs per submission. Then I calculate the maximum range value by adding the number of docs per submission to the minimum range value and subtracting one to account for the fact that the loop is zero based. Once we have the minimum and maximum range values, we select those documents and submit for renditioning.

<# Loop through each iteration specifying range of documents.
    Should return 5 (or less) document objects for each iteration. #>
for ($x = 0; $x -lt $Iterations; $x++) {

    Write-Host "$x of $Iterations iteration"
    Write-Host '**********************************'

    <# Determine range minimum
        Multiple the index (x) value by the number of docs per submission (5). #>
    $Range_Min = $x * $NumberOfDocsPerSubmission

    <# Determine range maximum
        Add number of docs per submission minus one to the range minimum. #>
    $Range_Max = $Range_Min + ($NumberOfDocsPerSubmission - 1)

    Write-Host "Range Minimum: $Range_Min; Maximum: $Range_Max"

    # Populate variable with range of document objects.
    $pwDocsToProcess = $pwDocs[$Range_Min..$Range_Max]
    Write-Host '----------------------------------'

    <# Output name of each document contained in the collection. 
        For demonstration purposes. #>

    Write-Host '**********************************'

    <# Submit collecttion for renditioning.
        Using Splat for readability. #>
    $Splat_Rendition = @{
        InputDocuments = $pwDocsToProcess
        ProfileName $RenditionProfile 
    New-PWRenditionRequest @Splat_Rendition -MakeSinglePlotRequest -Verbose

The following shows the output in the console, without the renditioning output.


The intent of this post was to demonstrate the use of the range, and how to determine the minimum and maximum values. Therefore, I will not show any of the rendition output.

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.

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 )

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.