0 votes

Hi, I need to create a number of mail user accounts via Adaxes and a lot of these accounts have & in the displayname/email address etc (I know, I know :)).

The new-mailuser command keeps failing as I suspect I am missing the "" around the items that contain an &. I have tried everything I can think of including "'$name'", ""$Name"" etc etc and I can't seem to get the custom command to add the "" around it.

Two questions really, how can I force the "" around the parameter with an & in or how to I get detailed error messages of why the command failed so I can troubleshoot it better. I have tried $context.logmessage($_.Exception.Message)

Thanks

by (50 points)

1 Answer

0 votes
by (12.5k points)
selected by
Best answer

Hello,

how can I force the "" around the parameter with an & in

All you need to do is to specify the variable value in double quotes. For example, if you specify the value explicitly, it should look like this:

$name = "John & Doe"
$address = "j&d@domain.com"
New-MailUser -Name $name -ExternalEmailAddress $address

how to I get detailed error messages of why the command failed so I can troubleshoot it better.

To catch the exception returned by a cmdlet, use a try/catch block. Also, you need to specify the Stop value in the ErrorAction parameter of the cmdlet. The whole approach should look like this:

try
{
    New-MailUser -Name $name -ExternalEmailAddress $address -ErrorAction Stop
}
catch
{
    $Context.LogMessage("The following error occurred: " + $_Exception.Message, "Warning")
}
0

Thanks, this has really helped.

Related questions

0 votes
1 answer

I'm currently receiving the below error when trying to remove or add actions to a web interface's homepage. I only get the error on this specific dashboard, others are ... the web interface there. I'm currently running Adaxes version 2021.1 if that helps

asked May 21, 2021 by richarddewis (260 points)
0 votes
0 answers

When the UPN being created is the same as an existing one except for the case. For instance, the new UPN is sally.fields but there's an existing Sally.Fields. The ... but then fails to create the AD account indicating that the UPN is not unique forestwide.

asked Jul 13, 2022 by sandramnc (870 points)
0 votes
1 answer

I'm trying to modify mailbox settings to add additional email addresses to a user after creation. This is a hybrid on-prem and Exchange Online with E5 licenses. Everything works up ... to a different OU during the process so I know the user exists. Any ideas?

asked Mar 6, 2023 by Michael Long (70 points)
+1 vote
1 answer

Since today were receiving the below error when attempting to add additional email addresses to users via Adaxes. An Azure Active Directory call was made to keep object in sync ... How do we fix to get the ability to add email addresses via Adaxes again?

asked Mar 1, 2021 by techg (320 points)
0 votes
1 answer

Our adaxes service account is able to create the mailbox when running our create user business rule, but cannot change any settings like disable OWA. What level of security will it need?

asked Apr 6, 2021 by bstone (50 points)
3,434 questions
3,130 answers
7,984 comments
546,354 users