#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

HowTo: Get List of Connected Users

In this post, I will show a quick way to get a list of connected users within the active ProjectWise datasource utilizing a method from the PWWrapper provided with the PWPS_DAB module. Performance for this process will depend on the number of users within your PW datasource.

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

  • Get-PWUsersByMatch

Get All ProjectWise Users

The following will return a datatable containing all user accounts and their connection status within the active ProjectWise datasource.

# Returns a list of all user objects.
$pwUsers = Get-PWUsersByMatch

# Create datatable to store results.
$dtUsers = [Data.Datatable]::new("Users")
$dtUsers.Columns.Add("UserName", [string]) | Out-Null
$dtUsers.Columns.Add("IsConnected", [bool]) | Out-Null

<# Loop through each user, determine if they are connected
and add to datatable. #>
foreach($pwUser in $pwUsers){ # break
<# Determine if the current user is connected. We use the aaApi_IsUserConnected method/function
included in the PWWrapper assembly provided with
the PWPS_DAB module. #>
$IsConnected = [PWWrapper]::aaApi_IsUserConnected($pwUser.ID) # Create new datatable row. $dr = $dtUsers.NewRow() # Set values for each column. $dr.UserName = $pwUser.Name $dr.IsConnected = $IsConnected # Add datarow to datatable. $dtUsers.Rows.Add($dr) } # Display results. $dtUsers | Out-GridView # Filter by IsConnected $dtUsers | Where-Object IsConnected -EQ $true

 


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.

1 thought on “HowTo: Get List of Connected Users”

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.