Issue

In Powershell all the Autodesk Vault users of a certain group should be determined via API.


Solution

The following function will return all users assigned to a given group:

function Get-UsersByGroup{
param(
[string]$groupName
)
    if( $vault -eq $null){
        echo 'Not connected to vault'
        return
    }
    try{
        $group = $vault.AdminService.GetGroupByName($groupName)
        $groupInfo = $vault.AdminService.GetGroupInfoByGroupId($group.Id)
        $groupInfo.Users | ForEach-Object { [array]$users += $_ }
        return $users
    }catch [Autodesk.Connectivity.WebServices.VaultServiceErrorException]{
        if ($_.Exception.Message -eq 160){
            echo 'Bad group name'
        } else {
            echo $_.Exception.Message
        }
    }
}
  • Check if there is an open connection to Vault
  • Request the groupID from Vault using the group name
  • Request group info for the retrieved groupID
  • Add all users in the group to an array and return the array


Example

To get all users of the group "Administrators" the function can be used like this:

Get-UsersByGroup 'Administrators'


Example result:

Id           : 7
Name         : TestAdmin
FirstName    : 
LastName     : 
Email        : 
CreateUserId : 2
CreateDate   : 11/16/2017 8:02:55 AM
IsActive     : True
IsSys        : False
Auth         : Vault


Remarks

  • Tested with Vault Professional 2018 and powerVault 18.0