r/PowerShell • u/TheLazyAdministrator • Jul 11 '18
Script Sharing [Tool] Create and Configure Active Directory and Office 365 Users at Once. Created w/ PowerShell Studio
Links
.Description
Quickly and easily create and configure Active Directory and Office 365 Users at once. In Active Directory Users and Computers if you want to enter items like E-Mail, password, group permissions, login scripts, home drive, etc. you would have to complete the new user wizard, find, and then edit your user in Active Directory, and fill in the necessary information. Master User Creator lets you configure hundreds of items for your user without ever leaving the wizard. You can configure items like:
Password (confirm your password and even generate a random password)
E-Mail
Specify an OU to place the new user in
Password settings (change password, disabled, never expires, etc)
Add your user to certain security groups
Logon Script
Home Folder (drive letter and location)
ProxyAddresses
Office 365 License
Multi-Factor Authentication
Alias E-Mail Addresses
Mail Groups (add your user to distribution groups, office 365 groups and mail-enabled security groups)
Security Groups (add your user to security groups)
Shared Mailboxes (grant your user Full Access, Send-As or Send on Behalf permissions on Shared Mailboxes, configure AutoMapping)
Hide from Global Address List
And More!
Active Directory User UI
Office 365 User UI
.Features
Logging
The console log will display everything it’s working on every step of the way. It will also display the PowerShell cmdlets, warnings and error messages.
Passwords
When creating your new user (AD or O365) you can either generate a random password or manually enter one in. PowerShell checks both strings and will not let you create your user if both passwords do not match. This ensures that it is entered correctly the first time.
Organizational Unit
When you create your Active Directory User you can specify which OU you want them to reside in by using the drop-down. If nothing is selected it will place them in whichever OU you configured new User objects to be placed in.
Office 365 Licenses
When creating an Office 365 user you can assign them a license right away. AccountSKUs are converted to friendly names to make picking out a license easier.
Shared Mailboxes
In the Shared Mailboxes tab, you can grant your user Full Access, Send-As, or Send on Behalf of permissions on Shared Mailboxes. If you select Full Access you can also configure AutoMapping (if the mailbox will automatically appear in the users Outlook).
Active Directory Groups
You can check which groups you want your user to be a member of. This allows you to configure things such as permissions during the new user creation process instead of after.
Multi-Factor Authentication
If you set Multi-Factor Authentication to True then MFA will be turned on when the user signs in for the first time. They will be prompted to set up MFA (they can enter their cell phone number to receive the MFA token via text) upon their first logon.
Dynamic Pre-Reqs Checks
Certain fields are required prior to creating your user. These fields will have an asterisk and be in red. Once they have enough valid data the field will change to black and the asterisk will be removed. The "Create User" button will remain disabled until you have met all the pre-reqs to ensure your user is created without issues.
AD Sync
If the ADSync module is detected on the system, the application will automatically enable the ADSync option and disable the manual user creation for Office 365 to allow you to automatically run an ADSync once your Active Directory User has been created.
Copy Attributes
When you go to create an Office 365 user, you have the option of copying the attributes you just entered for your Office 365 user. This is extremely beneficial in environments that do not have ADSync set up. Instead of entering everything twice, you can just click a button and everything will copy over.
Prerequisites
PowerShell v3 or higher with Execution policy set to RemoteSigned or Unrestricted
MSOnline Module (If configuring O365 User)
ADModule (It can run on a domain joined machine with RSAT tools installed as well as on domain controllers)
3
u/TheAgreeableCow Jul 11 '18
Nice work on the AD Sync bypass. Was wondering why you would persist with creating manually in both environments.
1
2
u/baconisgooder Jul 11 '18
How would this work if you are in a hybrid setup with Exchange?
2
u/TheLazyAdministrator Jul 12 '18
At the moment it would not since it creates the mailbox in exchange online and not on premise exchange.
3
u/SaladProblems Jul 12 '18 edited Jul 12 '18
I haven't been using Exchange for a while now, but I used to just use New-RemoteMailbox, which would create the user account on-prem, and o365 would provision the mailbox on the next sync, all in one step. The user account was created on the AD side, so I would add any group memberships it needed while the mailbox was still pending.
20
7
1
u/fonetik Jul 12 '18
Looks great!
How does this work with admins that use 2FA? We require it and it has been hell to script with.
5
u/TheLazyAdministrator Jul 12 '18
To connect to Exchange online with MFA you need an extra module in your tenant. I assume you probably already have it since you know how much of a pain it is to script with it.
The first page on the app you can select if you use MFA to log into office 365. If so it will use that MFA exchange online module and MSOnline so it will correctly prompt for your token
2
u/TheLazyAdministrator Jul 16 '18
MFA works a little better in v1.0.1, it will let you know if you do not have the MFA module
2
u/ThatMitchJ Jul 12 '18
Unless I'm missing something, I for one don't find scripting around MFA vastly different than without it. The vast majority of scripts out there use a get-credential command somewhere in them. Remove this command and everything else is virtually identical. Office will automatically handle prompting for credentials for either MFA or not when connect-msolservice is called, so the get-credential command isn't really needed anyways.
2
u/fonetik Jul 12 '18
It works well for simple commands. When there are commands that take longer than a few minutes, it fails. It has some other weird inconsistencies where some scripts just work if it's off and don't work when it is turned on.
Not terribly impressed with the 2FA options so far. Ideally, they would have what a lot of other sites have where you can validate the 2FA portion once and it doesn't ask again for 24 hours. Not sure if there's a technical reason why that can't happen here.
1
u/albus_fulger Jul 12 '18
Any tips on learning Powershell Studio? I've been working in it some, but it's pretty overwhelming at times.
3
u/TheLazyAdministrator Jul 12 '18
I just learned by making applications on it. I do recommend this book though it’s great
3
3
u/bsnotreallyworking Jul 11 '18
I've been toying with the idea of streamlining the onboard process in a similar fashion. Currently, the mailbox is created in Exchange Management on-prem, then migrated to o365 via Powershell.
Might have to check out your source and cobble together my own.
Thanks for this!
5
u/ablege Jul 11 '18
You can create the onprem AD account then use enable-remotemailbox in the Exchange Management Shell to mail enable the object, apply the aliases, etc. No need to create/migrate an onprem mailbox.
2
u/AdmiralCA Jul 12 '18
Or simplify even further by creating the AD account in the same cmdlet with New-RemoteMailbox
2
0
0
Jul 11 '18
[deleted]
2
u/TheLazyAdministrator Jul 11 '18
Yes, this looks a little similar, quite a bit more functionality in the Tool I linked. Looks like other users in that thread made similar tools as well. Whatever works!
3
u/ThatMitchJ Jul 12 '18
With a workflow like creating users I'm sure there are thousands of different variations out there. Each one is a little different than the last. The one you linked seems decent, but not as feature rich as the one in this thread, though because it's CLI based, and not GUI based, it might be better in some circumstances. I for one would lean towards the CLI method myself, because then I can pass parameters and use the automation in other ways (think read required information from our ticketing system or HR application to add another layer of automation).
The one in this thread has more features, including a GUI. The GUI is very nice and familiar for people who are used to using ADUC to create their users.
If you look around on this sub, you'll see a ton of user creation scripts. Each one slightly different and each one with different ways of achieving similar goals.
5
u/tigerguppy126 Jul 12 '18
I was about 80% done with something very similar...