Creating a Basic Report Using the API

Modified on Fri, 6 Dec at 4:06 PM

TABLE OF CONTENTS

The aim of this article is to show how to extract data from the ManagementStudio API. This is aimed at users who are new to the API and shows all the steps involved.


Prerequisites

  • Install Microsoft Visual Studio Code (free download)
  • Open Microsoft Visual Studio Code and install all addins and updates if prompted (eg. PowerShell extension)
  • Install ManagementStudio v10

Install the Software Development Kit




  • Download the ManagementStudio Software Development Kit (SDK) zip file. This can be located by appending "/project/sdk" to the ManagementStudio URL. Example: If you use the install URL http://managementStudioserver:5000/Install then use this URL to download the SDK zip file: http://managementStudioserver:5000/project/sdk 
  • Logon by entering your ManagementStudio username and password
  • Right-click the downloaded zip file -> Properties -> Unblock -> OK


  • Unzip this file to a local folder on your device such as C:\MigStudio_SDK
  • Verify that two subfolders have been created within this folder: ManagementStudioApi and zExamples

Preparing to Run a Report

  • Open the example script Ex 2. Move Processes.ps1 in Visual Source Code which is located in the zExamples folder
  • In the line which starts $isLoggedIn change the username and password to a known set of credentials
  • In the same line modify the ProjectId to match the Project you would like to report on. The ProjectId can be found in ManagementStudio -> Admin -> Project Settings




  • Comment out the line outlined below by typing the # character at the start of the line

  • Click Run -> Start Debugging, or click the play button (top-right) or press F5. The script will run. In the Terminal panel you should see confirmation that the script has successfully connected to the API


Create a Simple User Migration Report

  • Ensure you have run the steps in the section 
  • Preparing to Run a Report above
  • Copy and paste the command below into the Terminal panel and press return. This will run the command and all the User Migration records will be displayed in the Terminal panel
Get-MSUserMigrations -All

Notes:

  • This will return all the fields for every User Migration
  • Press CTRL-C to stop the command mid-way through running (this can be useful if the output is excessively long)


  • To display the results in a table in a new window use the following command:
Get-MSUserMigrations -All | Out-GridView
  • To limit this to 10 records use the following command:
Get-MSUserMigrations -All -Take 10 | Out-GridView




Create a Simple Application Report

  • Ensure you have run the steps in the section Preparing to Run a Report above
  • To get a list of the first 10 applications in ManagementStudio run this command in the Visual Studio Code application:
Get-MSApplications -All -Take 10

Notes:

  • This will return all the fields for each application
  • Press CTRL-C to stop the command mid-way through running (this can be useful if the output is excessively long)


To display this data in a table in a new window run:

Get-MSApplications -All -Take 10 | Out-GridView



Create a Report showing Users and their Applications

  • Ensure you have run the steps in the section Preparing to Run a Report above
  • Copy and paste the following commands into the Terminal pane in the Visual Studio Code window and press Return:
$TApps1 = New-MSDataminingTier -Module Applications -Fields @('AppVendor','AppName','AppVersion')
$Rpt = Get-MSUserMigrations -All -Take 3 -IdsOnly | Get-MSUserMigrationDataminingReport -Fields @('Firstname', 'LastName') -AdditionalTiers @($TApps1) 
$Rpt.data | Out-GridView

Notes: 

  • This will produce a report in a separate windows showing the first three users with their appliactions
  • The first command creates an apps data mining tier object with the application vendor, name and version
  • The second command gets the first three User Migrations and links them with the apps tier and stores them in the $Rpt obejct
  • The third command outputs the $Rpt object into a new window



Further Support

If you require further support, please visit ManagementStudio's Service Desk to search the knowledge base or create a new support ticket.