ACCESSING the API This Mini-Guide Runs Through the Steps Required to Get Started Using the Migrationstudio API Via a Powershell Script
Total Page:16
File Type:pdf, Size:1020Kb
ACCESSING THE API This mini-guide runs through the steps required to get started using the MigrationStudio API via a PowerShell script. PREREQUISITES You’ll need the following to have been setup be able to access the API 1. Logon for MigrationStudio with admin rights 2. API account enabled 3. API account username and password CREATE THE SCRIPT 1. Create a folder on your device called “API Test”. The location of this folder isn’t important. 2. Open the MigrationStudio Portal 3. Admin -> File Manager 4. In the left-hand pane of the File Manager browse to Customisation\PowerShell\ 5. Double click Template.ps1 -> Save -> Save into the local API Test folder you created 6. In the left-hand pane of the File Manager browse to Customisation\PowerShell\Modules 7. Double-click the following files and save them into a Modules subfolder in the local API Test folder: Required: AppTracker-Commands.psm1 MigrationStudio.PowerShell.dll AppTracker Helper Functions v2.ps1 AppTracker Helper Functions.ps1 Optional: AppTracker-Commands.Help.xml DocumentFormat.OpenXml.dll SpreadsheetLight.dll 8. In the local API Test folder make a copy of Template.ps1. Rename this file APITest.ps1 9. Right-click APITest.ps1 -> Edit to open in PowerShell ISE 10. Modify the $ScriptName variable to “First API Test” 11. Change the hostname in $debugApiUri to the MigrationStudio IIS server hostname 12. If required, add the IIS folder name such as “/MigrationStudio” after the hostname (this should match the address used to access MigrationStudio via a web browser) 13. Delete the “#” at the start of the line: #$ApiUserName = "api_account"; $ApiPassword = "Password!" 14. Change the password in that line to match the API account password 15. By default the following two commands will be enabled in the script. These are useful for testing connectivity with the API: TESTING THE SCRIPT 1. In the PowerShell ISE press F5 to run script 2. You should now see all the applications listed in the PowerShell ISE window OTHER USEFUL COMMANDS 1. To export the applications into a CSV file you can replace the two existing commands with the following two commands: $theApps=Get-ATAllApplications -AppTrackerAPI $api $theapps | Export-Csv -Path ([Environment]::GetFolderPath("Desktop")+"\API Test\Apps.csv") -Delimiter ',' -NoTypeInformation 2. Command to export users (all data fields): $theUsers=Get-ATAllUserMigrations -AppTrackerAPI $api $theUsers | Export-Csv -Path ([Environment]::GetFolderPath("Desktop")+"\API Test\UsersAllFields.csv") -Delimiter ',' -NoTypeInformation 3. Command to export users (First name, Last name and SAM account fields) $theUsers=Get-ATAllUserMigrations -AppTrackerAPI $api $theUsers | Select-object FirstName,LastName,SamAccount | Export-Csv -Path ([Environment]::GetFolderPath("Desktop")+"\API Test\UsersSpecificFields.csv") -Delimiter ',' -NoTypeInformation REFERENCE 1. For details on the available API commands see: [IIS folder]\MigrationStudio\Portal\Customisation\PowerShell\Modules\AppTracker-Commands.psm1 CTRL-M to collapse all regions Expand #region – Application Functions… for AppTracker commands 2. For further info on the API refer to [IIS folder]\MigrationStudio\Portal\Customisation\PowerShell\ReadMe.txt .