https://github.com/tools4everbv/helloid-task-sa-target-activedirectory-accountcreate
Active Directory - User account create
https://github.com/tools4everbv/helloid-task-sa-target-activedirectory-accountcreate
active-directory delegated-form powershell product service-automation task
Last synced: 7 months ago
JSON representation
Active Directory - User account create
- Host: GitHub
- URL: https://github.com/tools4everbv/helloid-task-sa-target-activedirectory-accountcreate
- Owner: Tools4everBV
- Created: 2023-02-20T12:48:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T15:12:58.000Z (about 2 years ago)
- Last Synced: 2025-06-13T09:44:20.953Z (9 months ago)
- Topics: active-directory, delegated-form, powershell, product, service-automation, task
- Language: PowerShell
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HelloID-Task-SA-Target-ActiveDirectory-AccountCreate
## Prerequisites
- [ ] The HelloID SA on-premises agent installed
- [ ] The `ActiveDirectory` module is installed on the server where the HelloID SA on-premises agent is running.
## Description
This code snippet will create a new user within Active Directory and executes the following tasks:
1. Define a hash table `$formObject`. The keys of the hash table represent the properties of the `New-ADUser` cmdlet, while the values represent the values entered in the form.
> To view an example of the form output, please refer to the JSON code pasted below.
```json
{
"Path": "",
"ChangePasswordAtLogon": true,
"PasswordNotRequired": true,
"Surname": "",
"Description": "",
"UserPrincipalName": "",
"GivenName": "",
"Name": "",
"Title": "",
"SamAccountName": "",
"AccountPassword": "",
"Enabled": true
}
```
> :exclamation: It is important to note that the names of your form fields might differ. Ensure that the `$formObject` hash table is appropriately adjusted to match your form fields. [See the Microsoft Docs page](https://learn.microsoft.com/en-us/powershell/module/activedirectory/new-aduser?view=windowsserver2022-ps)
2. Imports the ActiveDirectory module.
3. Verify if the user that must be created already exists based on the `userPrincipalName` using the `Get-ADUser` cmdlet.
4. If the user does not exist, a new user is created using the `New-ADUser` cmdlet. The hash table called `$formObject` is passed to the `New-ADUser` cmdlet using the `@` symbol in front of the hash table name.
> :bulb: Splatting is a technique in PowerShell where you store the parameters and their values in a hash table, and then pass the hash table to a cmdlet or function.