I'm assuming its obvious, but I'm completely missing it. I've got a PowerShell script I'm working on to automate user creation. One of my functions generates the email address. Right now, its not doing anything fancy, just joining the username and domain. I'll be adding more later to increment the value if in use. But I can't get the basic version to work.
function generateMailbox {
param(
[parameter(Mandatory=$true)]
$userName,
[parameter(Mandatory=$true)]
$domain
)
$uniqueMailbox = $null
#set initial value for $uniqueMailbox as the initial mailbox name
$uniqueMailbox = "$userName@$domain"
return $uniqueMailbox
}
So, pretty straightforward. BUT... the "@" is missing from the emails it generates. I put in a break point on the return and verified $uniquemailbox is missing that "@". So if $userName = "uname"
and $domain = "domain.com"
, then $uniqueMailbox will be set to "unamedomain.com"
While in the debug mode, I can manually enter $uniqueMailbox = "$userName@$domain"
and then the value returns correctly. For the life of me I can't see my mistake.
I did double check the $uniqueMailbox
variable isn't used anywhere outside this function.