#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

HowTo: Get and Set User Settings Using PowerShell with PWPS_DAB (64-Bit)

There have been many, many requests asking for the ability to get and set user settings and user default settings within a 64-bit session of PowerShell. Thanks to Dave B. this functionality has been added to the PWPS_DAB module in version 1.10.1.0.

We now have three new cmdlets:

  • Get-PWUserDefaultSettings
  • Get-PWUserSettingByUser
  • Update-PWUserSetting.

I would recommend looking at the help information to become better acquainted with each cmdlet and their functionality, corresponding parameters, etc.  There are a large number of user settings available, so spend some time familiarizing yourself with them.

In this post we will look at a few of the more common settings, Working Directory, Show descriptions instead of names, and show all versions.

Before we look at individual settings, lets get the default user settings.

# Returns all Default User Settings and values.
Get-PWUserDefaultSettings

The following shows a small subset of the available default user settings and the corresponding values. There are 142 individual user settings.

defaultsettings


Now, we can take a look at a few of the user settings.  I am going to populate a variable with a ProjectWise User object for my user account to pass to each of the cmdlets.  Keep in mind, you can pass one or more ProjectWise user objects to the  InputUsers parameter.

# Populate pwUser variable with a ProjectWise User object.
$pwUser = Get-PWUsersByMatch -UserName 'brian.flaherty'

The following shows the content of the ProjectWise User object returned.

userobject

Next, we will get the user setting for the working directory when using ProjectWise Explorer.

# Working Directory when using ProjectWise Explorer
$pwWorkDir = Get-PWUserSettingByUser -InputUsers $pwUser -SettingName WorkDir_WhenUsingPWExplorer

The following shows the result.

wkdir

The following shows the same setting and value when looking at the user settings within the ProjectWise Administrator.

usersettings1

Next, we will get the user setting for Show Descriptions Instead of Names.

# Setting value for Show Descriptions instead of names
$pwShowDesc = Get-PWUserSettingByUser -InputUsers $pwUser -SettingName UI_ShowDescriptionsInsteadOfNames

The following shows the result. For this setting, the value will always be a 0 (zero) for off or a 1 (one) for on..

desc2

The following shows the same setting and value when looking at the user settings within the ProjectWise Administrator.

usersettings2

Now, we will get the user setting for Show All Versions.

# Setting value for Show all versions
$pwShowAllVersions = Get-PWUserSettingByUser -InputUsers $pwUser -SettingName DocList_ShowAllVersions

The following shows the result.

v

The following shows the same setting and value when looking at the user settings within the ProjectWise Administrator.

usersettings4


Now that we’ve seen the three settings and the current values, lets make some changes.

First, we will update the working directory to use a folder on the D drive.

# Update working directory to point to a different folder on the local machine.
$NewWorkDir = 'd:\ProjectWise\WorkingDirectories\$User.Name$'
Update-PWUserSetting -InputUsers $pwUser -SettingName WorkDir_WhenUsingPWExplorer -SettingValue $NewWorkDir

The following shows the new value.

There is one caveat with this setting. When using  $User.Name$, be sure to wrap the entire value within single quotes (‘), not double quotes (“), otherwise the $User will be treated as a variable and PowerShell will attempt to put a value in its place.

wd1

Next, we will toggle OFF the Show Descriptions instead of names user setting. We will be setting the value to 0 (zero).

# Toggle On Show Descriptions instead of names
$NewShowDescValue = 0 # This value can only be a 0 or 1. Off or On respectively.
Update-PWUserSetting -InputUsers $pwUser -SettingName UI_ShowDescriptionsInsteadOfNames -SettingValue $NewShowDescValue

The following shows the new value.

desc3

Finally, we will toggle OFF the Show all versions user setting. We will be setting the value to 0 (zero).

# Toggle Off Show all versions
$NewShowVersionsValue = 0 # This value can only be a 0 or 1. Off or On respectively.
Update-PWUserSetting -InputUsers $pwUser -SettingName DocList_ShowAllVersions -SettingValue $NewShowVersionsValue

The following shows the new value.

v2

This is just a small sample of the user settings available and how to update them.

 

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 )

Google photo

You are commenting using your Google 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.