$acceptedDomains = Get-AcceptedDomain ;
if ($acceptedDomains -eq $null)
{
WriteError ("There is no accepted domain so user can not be created.")
}
$acceptedDomain = $acceptedDomains[0].Name;
if($UseDomainController -eq $true)
{
$user = New-MailUser -Name $username -DomainController $DomainController -ExternalEmailAddress $username@$acceptedDomain;
set-mailuser -Identity $user.Identity -HiddenFromAddressListsEnabled $true -DomainController $DomainController
}
else
{
$user = New-MailUser -Name $username -ExternalEmailAddress $username@$acceptedDomain;
$acceptedDomains = Get-AcceptedDomain | ? {$_.Default -eq "True"} ;
if ($acceptedDomains -eq $null)
{
WriteError ("There is no accepted domain so user can not be created.")
}
$acceptedDomain = $acceptedDomains.DomainName;
if($UseDomainController -eq $true)
{
$user = New-MailUser -Name $username -DomainController $DomainController -ExternalEmailAddress $username@$acceptedDomain;
set-mailuser -Identity $user.Identity -HiddenFromAddressListsEnabled $true -DomainController $DomainController
}
else
{
$user = New-MailUser -Name $username -ExternalEmailAddress $username@$acceptedDomain;
set-mailuser -Identity $user.Identity -HiddenFromAddressListsEnabled $true;
}
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)