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 (14.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

Hi All, I have setup an action to cancel all meetings in outlook when a user is leaving. We use Exchange online but I'm getting an error 'The operation is supported by Exchange online and Exchange versions starting from 2019' I cant see where you specify.

asked Sep 6 by DarrenFisk (60 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)
3,564 questions
3,255 answers
8,264 comments
547,914 users