Issue
For some workflows it is necessary to know which Vault user created a job. For example when their name or their email address is required within a job.
Solution
In order for this function to work powerVault and a Vault connection are needed:
Import-Module powerVault Open-VaultConnection -Vault "VaultName" -Server "ServerName" -User "UserName" -Password "Password"
You have to get the user's id from the job in the job queue. With that id you can retrieve the matching user object..
function Get-VaultJobCreator { <# .SYNOPSIS Returns a Vault user object .DESCRIPTION This function checks if the current user has permissions to retrieve the user information. If it doesn't the function logs a warning and does nothing. If it does the function returns an Autodesk.Connectivity.WebServices.User object. .EXAMPLE $JobCreator = Get-VaultJobCreator -JobId $job.Id $JobCreator.Name $JobCreator.Id $JobCreator.Email #> param( [ValidateNotNullOrEmpty()] [long]$JobId ) if(-not $vault.JobService.CheckRolePermissions(@("GetJobsByDate"))) { Write-Host "User needs 'JobQueueRead' permission to execute GetJobsByDate" return } if(-not $vault.AdminService.CheckRolePermissions(@("GetUserByUserId"))) { Write-Host "User needs 'AdminUserRead' permission to execute GetUserInfoByUserId" return } [array]$allJobs = $vault.JobService.GetJobsByDate([int]::MaxValue,[DateTime]::MinValue) $currentJob = $allJobs | ? { $_.Id -eq $JobId } $user = $vault.AdminService.GetUserByUserId($currentJob.CreateUserId) return $user }