Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Create User

view on GitHub

Create User is available as both a pgutil command and an HTTP Request, and will create a new User account in ProGet.

Command Specification (CLI)

The security users create command is used to create a new User.

The --username, --displayname, and --email options are always required.

If --password is not specified, the User will be prompted to manually input a password and retype it to confirm.

Creating a user requires the the user name (e.g. "John Smith"), display name (e.g. jsmith), and the email address (e.g john@kramerica.com). You can also include a password (e.g. abc12345).

pgutil security users create --username="John Smith" --displayname=jsmith --email=john@kramerica.com  --password=password123

HTTP Request Specification

To create a new User account, simply POST to the following URL with an appropriate API Key and a SecurityUser object (see SecurityUser.cs) object as the request body.

POST /api/security/users/add

HTTP Response Specification

A SecurityUser object will be returned on a successful 200 response. A 403 response indicates a missing, unknown, or unauthorized API Key.

Sample Usage Scripts

The following scripts will import a CSV of user information and create users in the specified ProGet instance in bulk. The CSV needs to formatted with the correct headers shown in this example:

Name,DisplayName,Email,Password
Alice Johnson,ajohnson,alice.johnson@example.com,Sunflower92!
Brian Lee,blee,brian.lee@example.com,MapleLeaf47#
Catherine Wu,cwu,catherine.wu@example.com,OceanWave88$
David Patel,dpatel,david.patel@example.com,StarryNight55@
Emily Torres,etorres,emily.torres@example.com,RiverStone31%

Create Users (Powershell)

This PowerShell script create users from a .csv file located at C:\Users\YourUser\Documents\users.csv to a ProGet instance located at proget.corp.local with an API key abc12345:

$csvPath = "C:\Users\YourUser\Documents\users.csv"
$hostname = "proget.corp.local"
$apiKey = "abc12345"

Import-Csv $csvPath | ForEach-Object {
    $body = $_ | Select-Object @{n='name';e={$_.Name}}, @{n='displayName';e={$_.DisplayName}}, @{n='email';e={$_.Email}}, @{n='password';e={$_.Password}} | ConvertTo-Json
    try {
        Invoke-RestMethod -Uri "https://$hostname/api/security/users/add" -Method Post -Headers @{ "X-ApiKey" = $apiKey; "Content-Type" = "application/json" } -Body $body
        Write-Host "Added: $($_.Name)"
    } catch { Write-Warning "Failed: $($_.Name) - $_" }
}

Write-Host "Done."

Example Output:

Added: Alice Johnson
Added: Brian Lee
Added: Catherine Wu
Added: David Patel
Added: Emily Torres
Done.

Create Users in Bulk (Python)

This Python script create users from a .csv file located at C:\Users\YourUser\Documents\users.csv to a ProGet instance located at proget.corp.local with an API key abc12345:

import csv
import requests

csv_file_path = r"C:\Users\YourUser\Documents\users.csv"
hostname = "proget.corp.local"
api_key = "abc12345"

api_url = f"https://{hostname}/api/security/users/add"
headers = {
    "X-ApiKey": api_key,
    "Content-Type": "application/json"
}

with open(csv_file_path, newline='', encoding='utf-8') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        payload = {
            "name": row["Name"],
            "displayName": row["DisplayName"],
            "email": row["Email"],
            "password": row["Password"]
        }

        try:
            response = requests.post(api_url, headers=headers, json=payload)
            response.raise_for_status()
            print(f"Added: {row['Name']}")
        except requests.exceptions.RequestException as e:
            print(f"Failed: {row['Name']} - {e}")

print("Done.")

Example Output:

Added: Alice Johnson
Added: Brian Lee
Added: Catherine Wu
Added: David Patel
Added: Emily Torres
Done.