#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

HowTo: Create Work Area and Connected Project

In this post, we will be stepping through the process of creating a new Work Area using the New-PWRichProject cmdlet and an associated Connected Project using the Add-PWConnectedProject.  We will also be using few other Connected Project related cmdlets for data validation and to obtain a token which is required for all of Connected Project cmdlets we will be using.

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.

  • New-PWRichProject
  • Get-PWConnectionClientToken
  • Get-PWConnectedProjectAssetTypes
  • Get-PWConnectedProjectDataLocations
  • Get-PWConnectedProjectIndustryTypes
  • Add-PWConnectedProject

Defining Variables

Before we get started, we will be creating some variables to be used for creating the Work Area and the Connected Project. 


# Variables for creating the Work Area.
# Fullpath and name of the Work Area to create.
$NewFolderPath = 'Projects\MyNewProject'
# Storage area to be used. Required.
$StorageArea = 'Storage02'
# Work Area type to be used. Required.
$ProjectType = 'General'

# Variables for creating the Connected Project.
$ConnectedProjectNumber = '123456-BMF'
$ConnectedProjectName = 'BMF-MyNewProject'
$AssetType = 'Process Manufacturing Plant'
$DataLocation = 'East US'
$Industry = 'Buildings And Facilities'
$Location = 'Navarre, FL'
$CountryCode = 'USA'

#endregion VARIABLES

Create Work Area

Now, we will create a new Work Area within our ProjectWise datasource. There are multiple ways to create a new Work Area, however we will be using the New-PWRichProject cmdlet.


$Splat_NewWorkArea = @{
NewFolderPath = $NewFolderPath
StorageArea = $StorageArea
ProjectType = $ProjectType
$newWorkArea = New-PWRichProject @Splat_NewWorkArea -Verbose


The following shows the contents of the Splat prior to running the cmdlet.


The following shows the new Work Area we just created. Notice there is not a Connected Project associated with it.


Get Required Token

We will now get a token to be used with the Connected Project cmdlets.

# Get required Token to create new Connected Project.
$Token = Get-PWConnectionClientToken

Validate Variable Entries

This section is not required. However, I like to verify my data prior to running any cmdlets. Each of the validation variables will be populated with a true or false indicating success or failure. These variables will be used when populating the Splat to create the Connected Project.


# Used to validate the provided Asset type.
$validateAssetType = if( Get-PWConnectedProjectAssetTypes -Token $Token |
Where-Object {$_ -eq $Type}) { $true } else { $false }

# Used to validate the provided Data Location.
$validateDataLocation = if( Get-PWConnectedProjectDataLocations -Token $Token |
Where-Object { $_ -eq $DataLocation }) { $true } else { $false }

# Used to validate the provided Industry.
$validateIndustry = if( Get-PWConnectedProjectIndustryTypes -Token $Token |
Where-Object { $_ -eq $Industry }) { $true } else { $false }


Populate the Splat

Here we will be populating the Splat to be used to create the Connected Project. We will be using the previously populated validation variables to determine whether some parameters should be included.


$Splat_NewConnectedProject = @{
InputFolder = $newWorkArea
Token = $Token
ConnectedProjectNumber = $ConnectedProjectNumber
ConnectedProjectName = $ConnectedProjectName
Location = $Location
CountryCode = $CountryCode

# Removing spaces to conform to allowed AssetType values.
$Splat_NewConnectedProject.AssetType = $($AssetType.Replace(' ', ''))
$Splat_NewConnectedProject.DataLocation = $DataLocation
# Removing spaces to conform to allowed Industry values.
$Splat_NewConnectedProject.Industry = $Industry.Replace(' ', '')


The following shows the contents of the Splat prior to running the cmdlet.


Create Connected Project

Finally, we will be creating the Connected Project using the populated Splat.


# Create new Connected Project and associate it with the provided Work Area.
$NewConnectedProject = Add-PWConnectedProject @Splat_NewConnectedProject -Verbose


The following images show the newly created Connected Project.


The following shows the Connected Project has been successfully associated with the Work Area.


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 “HowTo: Create Work Area and Connected Project”

  1. Getting a couple errors: PS C:\windows\system32> $validateDataLocation = if( Get-PWConnectedProjectDataLocations -Token $Token |
    Where-Object { $_ -eq $DataLocation }) { $true } else { $false }
    Get-PWConnectedProjectDataLocations : One or more errors occurred.
    At line:1 char:29
    + … ataLocation = if( Get-PWConnectedProjectDataLocations -Token $Token |
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Get-PWConnectedProjectDataLocations], AggregateException
    + FullyQualifiedErrorId : System.AggregateException,PWPS_DAB.GetPWConnectedProjectDataLocations



    VERBOSE: Location: Delaware
    VERBOSE: CountryCode: USA
    VERBOSE: Industry: 12
    VERBOSE: AssetType: 9999
    VERBOSE: DataLocationId: 99999999-9999-9999-9999-999999999999
    VERBOSE: BaseURL: https://connect-contextregistry.bentley.com
    WARNING: Error: Response at ‘https://connect-contextregistry.bentley.com’, ‘sv1.0/Repositories/BentleyCONNECT–Main/ConnectedContext/Project’ was null.

    Any clues?


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.