<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">
Defrag This

| Read. Reflect. Reboot.

Creating New Users in MOVEit Transfer 2018 with PowerShell

Adam Bertram| April 25 2018

| security

creating-new-users-moveit-transfer-powershell

In the previous articles, we focused on MOVEit Automation's REST API, but it’s now time to focus on MOVEit Transfer.

To get started with MOVEit Transfer’s API, we’ll again have to grab an access token. We’ll then use this access token throughout all of the API calls we make to the MOVEit Transfer API. The process is the same as MOVEit Automation. The only difference is the URL endpoint to connect to.

Say goodbye to end users using Dropbox and Google Drive. MOVEit 2018 makes file  transfers easy for users. Try MOVEit 2018 today.

Below is the PowerShell code you can use to get a token.

$hostName = 'MyMoveITTransferServer'
$authEndpointUrl = "https://$hostName/api/v1/token"
$authHttpBody = @{
    grant_type = 'password'
    username   = 'myuser'
    password   = 'mypassword'
}

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
$token = Invoke-RestMethod  -Uri $authEndpointUrl -Method 'POST' -Body $authHttpBody
$token = $token.access_token

Related: Using The New MOVEit 2018 REST API With PowerShell

Once you’ve got the token, it’s now time to create the new user. The most important part of this task and with all API operations using the MOVEit REST API is to get the JSON body you’ll be sending to the API correctly. The JSON body is the main component of the call and is used to store all of the attributes of the user being created. To create a new user, we first need to create a text file in JSON representing the user attributes. Below is an example.

JSON {     "fullName": "Adam Bertram",     "username": "abertam",     "password": "passwordhere12",     "email": "adam@adamtheautomator.com",     "permission": "User",     "mustChangePassword": true,     "notes": "Coolest automator ever!",     "homeFolderPath": "/home/abertram",     "homeFolderInUseOption": "AllowIfExists"  }

I’m going to assume this JSON file path is at C:.json on your local computer. Once you’ve got the JSON file created, it’s then time to gather up all of the parameters you’ll be passing to the Invoke-RestMethod command in PowerShell. Since we covered these parameters in previous articles, I’ll just document them here.

  • Uri : The API endpoint to connect to
  • Headers : The Authorization header containing the access token
  • Method : The HTTP method to use when making the API call
  • Body : The JSON text from the file we created.
  • ContenetType : The type of text in Body. This will always be application/json

The parameters can be stored in a hashtable.

$newUserParams = @{
    Uri         = 'https://<MoveITTransferServerNam>/api/v1/users'
    Headers     = @{ 'Authorization' = "Bearer $token" }
    Method      = 'POST'
    Body        = (Get-Content -Raw -Path 'C:\DemoUser.json')
    ContentType = 'application/json'
}

Once all of the parameters have been defined, we can then pass them all to Invoke-RestMethod at once using splatting.

PS> Invoke-RestMethod @newUserParams

emailFormat          : HTML
notes                : Coolest automator ever!
statusNote           :
passwordChangeStamp  : 2018-03-17T13:26:02
receivesNotification : ReceivesNotifications
forceChangePassword  : False
folderQuota          : 0
authMethod           : MOVEitOnly
language             : en
homeFolderID         : 464845759
defaultFolderID      : 464845759
expirationPolicyID   : 0
id                   : ua26iyn8v6q49l8g
orgID                : 7797
username             : abertam
realname             : abertam
permission           : User
email                : adam@adamtheautomator.com
status               : Active
lastLoginStamp       : 0001-01-01T00:00:00

If you receive an output like above, that means it was successful. To confirm, log into the MoveIT Transfer web interface, and you should see the user created!

Topics: security

Leave a Reply

Your email address will not be published. Required fields are marked *

THIS POST WAS WRITTEN BY Adam Bertram

Adam Bertram is a 20-year veteran of IT. He’s currently an automation engineer, blogger, independent consultant, freelance writer, author, and trainer. Adam focuses on DevOps, system management, and automation technologies as well as various cloud platforms. He is a Microsoft Cloud and Datacenter Management MVP and efficiency nerd that enjoys teaching others a better way to leverage automation.

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.