#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

How To: Get and Set “Use Access Control” within 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.

Many times, when running PowerShell scripts which are processing a lot of documents and/or projects, having access control turned off for the ProjectWise user account will decrease the amount of time in which it takes for the task to complete. So, how can you do this within PowerShell?

With the release of PWPS_DAB module version 1.9.2.0, we have added the ability to get and set the “Use access control” user property.  From within the user properties dialog, the “Use access control” property is located in the General section on the Settings tab as shown in the image below.

accesscontrol

Take a look at the help for each of the cmdlets to become familiar with their functionality, available parameters, etc.

  • Get-PWUserHasUseAccessControlOn
  • Set-PWUserUseAccessControl

Get-PWUserHasUseAccessControlOn

The Get-PWUserHasUseAccessControlOn cmdlet allows you to get the current setting for the “Use access control” user setting for the current user or one or more user accounts. The cmdlet has only one available parameter, -Users. You can pass an array of user objects to the cmdlet via the pipeline to get the  corresponding setting value for each user.

You can also, not include any user objects and the setting for the  current user will be returned as shown in the image below.

accesscontrol1

Set-PWUserUseAccessControl

The Set-PWUserUseAccessControl allows you to turn on / off the “Use access control” user setting for the current user or one or more user objects. This cmdlet has two parameters available, -Users and -Turnoff. The -Users parameter accepts an array of user objects via the pipeline to update.  The -Turnoff switch parameter, when included, will toggle off the “Use access control” option for the current user or the user object(s) passed via the pipeline.

When you make a change to the current user account, you will receive a warning message informing you that you will need to log out and log back in to ProjectWise in order for the change to take affect as shown in the image below.

accesscontrol2

The following demonstrates passing a few user objects via the pipeline to the                 Set-PWUserUseAccessControl cmdlet.  Because the -Turnoff parameter was included, the “Use access control” user setting is turned off for all user objects passed.

accesscontrol3

In the following, we pass the same three user objects to the Set-PWUserUseAccessControl cmdlet, and because we did not include the -Turnoff parameter, the “Use access control” user setting is turned back on.

accesscontrol4

Experiment with it and have fun.

Hopefully, you find this useful. Please let me know if you have any questions or comments.

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.