Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This is the thirdin a series of articles giving extended example of how to use the RestAPI. This article will demonstrate how to generate a report equivalent to the Version 3 "OutputUsers" view using PowerShell.

You can download the latest version of the file: OutputUsers.ps1, and simply customise the $user, $pass and $sonar values and it should run in your environment

Fields in the original report

FieldV3 CommentRestAPI Comment
AccountAccount Name / User Name from the Enterprise Application
eMail(This was not used in V3)Not implemented in V4
UserIDUserID from the application. V3 allowed Account and UserID to be distinctIn V4 this is the same as the Account
SoftwareNameEnterprise application nameE.g. Oracle Database Server, SQL Server, Active Directory Server, Informix
Module Name(This was not used in V3)Not implemented in V4
Application IDIdentifier for the application. Used to map to OutputApplicationsIn V4 this is in GUID format
DeviceIDIdentifier for the application. Used to map to OutputDevicesIn V4 this is in GUID format
RoleUser Role within the Enterprise ApplicationNot present for all application types

...

Build the CSV file header row

PowerShell has a number of built in libraries for handling output to various file formats. For this example we will be saving the results in a CSV file that can be viewed directly in EXCEL or imported into other databases.


Code Block
languagepowershell
themeMidnight
titleDefine columns
# Build the CSV File header row
$csv = @()
$row = New-Object System.Object

# email and ModuleName will always be NULL. Omit if not needed for backwards compatibility
$row | Add-Member -MemberType NoteProperty -Name "Account" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "eMail" -Value $null		
$row | Add-Member -MemberType NoteProperty -Name "UserID" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "SoftwareName" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "ModuleName" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "ApplicationID" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "DeviceID" -Value $null
$row | Add-Member -MemberType NoteProperty -Name "Role" -Value $null

...