Before using this snippet, verify you've met with the following requirements:
- User defined variables:
$ExchangeAdminUsername,$ExchangeAdminPasswordand$ExchangeConnectionUricreated in your HelloID portal. See also Custom Variables
This code snippet executes the following tasks:
- Define a hash table
$formObject. The keys of the hash table represent the properties of theNew-DistributionGroupcmdlet, 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.
{
"Name": "DistributionGroup1",
"DisplayName": "DistributionGroup1",
"PrimarySmtpAddress": "DistributionGroup1@mytestenvironment.dev",
"Alias": "DistributionGroup1",
"OU" : "testenvironment.dev/ExchangeDistributionGroups"
}❗ It is important to note that the names of your form fields might differ. Ensure that the
$formObjecthashtable is appropriately adjusted to match your form fields.
-
Constructs a PowerShell credential object from the supplied administrative username and password
-
Connects with the credentials to the Exchange on premises environment by means of the
New-PSSessioncmdlet -
Calls the
New-DistributionGroupcmdlet to create the new Distribution Group -
Disconnects from the Exchange session by means of the
Remove-PsSessioncmdlet