Powershell script to create user, mailbox and put into AD group

Man of Honour
Joined
20 Sep 2006
Posts
36,100
I know there's loads of examples around the net, but I'm wondering if someone knows of or has access to a basic one? Environment is 2012R2 with Exchange 2016 and just a couple of groups in AD.

Thanks.
 
Legend.

If I wanted firstname.lastname as the SAM and lastname, firstname as the DisplayName would I do:
$SAM = $UserFirstname + "." + $UserLastName
$DisplayName = $UserLastName + "," + " " + $UserFirstName

?
 
Ah, thanks.

Not working right now as it looks to be a little different with Exchange 2016, you can't just add a PSSnapin anymore.

Might build a home lab and do some experimenting.
 
The uri is the fully qualified domain name of the exchange server, so if your exchange server was 'srv-exchange' and your domain was 'college.local' then the fqdn would be 'srv-exchange.college.local'

That's what I thought, but it's not working.

You can sometimes avoid the + thing totally, powershell does let you use vars in strings like this:

$FirstName = "Bill"
$LastName = "Hats"
"$FirstName.$LastName"
"$FirstName, $LastName"

Nice tip, thanks.
 
Silly me, I had an = in front of the uri. No idea where that came from. On another error now, I need to develop this at home or on Azure a bit more I think.
 
Back
Top Bottom