https://github.com/tools4everbv/helloid-task-sa-target-activedirectory-accountenable
Active Directory - User account enable
https://github.com/tools4everbv/helloid-task-sa-target-activedirectory-accountenable
active-directory delegated-form powershell product service-automation task
Last synced: over 1 year ago
JSON representation
Active Directory - User account enable
- Host: GitHub
- URL: https://github.com/tools4everbv/helloid-task-sa-target-activedirectory-accountenable
- Owner: Tools4everBV
- Created: 2023-02-23T13:19:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-09T15:13:13.000Z (over 2 years ago)
- Last Synced: 2025-01-08T10:45:43.163Z (over 1 year ago)
- Topics: active-directory, delegated-form, powershell, product, service-automation, task
- Language: PowerShell
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# HelloID-Task-SA-Target-ActiveDirectory-AccountEnable
## 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 enable a user within Active Directory and executes the following tasks:
1. Defines a hash table `$formObject`. The keys of the hash table represent the properties of the `Get-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
{
"UserPrincipalName": "testuser@mydomain.local"
}
```
> :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/enable-adaccount?view=windowsserver2022-ps)
2. Imports the ActiveDirectory module.
3. Verifies that the account that must be enabled exists based on the `userPrincipalName` using the `Get-ADUser` cmdlet.
4. If the user does exist, the account is enabled using the `Enable-ADUser` cmdlet, otherwise an error is generated.