Creating New Users in MOVEit Transfer 2018 with PowerShell

Creating New Users in MOVEit Transfer 2018 with PowerShell

Posted on April 25, 2018 0 Comments

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.

There are 9 reasons why your IT team needs to adopt cloud monitoring. Download  this eBook to learn more.

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://<moveittransferservername>/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!

Adam Bertram

Adam Bertram is a 25+ year IT veteran and an experienced online business professional. He’s a successful blogger, consultant, 6x Microsoft MVP, trainer, published author and freelance writer for dozens of publications. For how-to tech tutorials, catch up with Adam at adamtheautomator.com, connect on LinkedIn or follow him on X at @adbertram.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation