HelloID-Task-SA-Target-ActiveDirectory-AccountDisable
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 disable a user within Active Directory and executes the following tasks:
- Define a hash table
$formObject
. The keys of the hash table represent the properties of theGet-ADUser
cmdlet, while the values represent the values entered in the form.
To view an example of a form output, please refer to the JSON code pasted below.
{
"UserPrincipalName": "[email protected]"
}
โ It is important to note that the names of your form fields might differ. Ensure that the
$formObject
hashtable is appropriately adjusted to match your form fields. See the Microsoft Docs page
-
Imports the ActiveDirectory module.
-
Verifies that the account that must be disabled exists based on the
userPrincipalName
using theGet-ADUser
cmdlet. -
If the user does exist, the account is disabled using the
Disable-ADUser
cmdlet, otherwise an error is generated.