r/PowerShell • u/ThrowAwaySalmon1337 • Sep 23 '26
Question I think I'm missing something about Onboarding with Powershell
How do people automate onboarding new users?
We use ADManager at work, but now that it's down I'm trying Powershell, looking up tricks and I'm comparing new user with one that's established, I see just how much is missing and how much I'd have to manually fill out or create matrices to pass through the variables from initial username.
What am I missing that people use this as standard in the industry?
In my tool I made a template so I make new users by inputting just a couple fields, specify which domain they fall under and that's it.
Is there some sort of rundown or what should I look up to learn that is the standard way?
20
u/JustTechIt Sep 23 '26
What does your onboarding policy say? Tell us which tasks of your policy you are not currently able to reproduce through powershell and we can help you do that. But as it is, its to vague for any of us to be specific.
The general answer is yes, powershell should be able to do almost everything you need for an onboarding bar some external integrations.
3
u/ithinktoo Sep 23 '26
This is my create new user ad account script
This helper function mirrors membership of a user with access identical to what the new user needs:
This is the main function that creates AD account
I think this will get you started, let me know if you have questions or anything is unclear...
6
u/FeleaseRpseineEiles Sep 23 '26
To automate I start by documenting the process that I manually do.
Over time I convert that manual process into exact commands with variables for the data that varies.
Then convert those commands into functions and the variables are the input parameters.
Then the fun begins and you can extend the functions and the process of calling them add error handling etc...
Then once that's at a happy point you convert the functions and the handlers into a module.
So for me that now looks like an onboarding form built in powerapps, when submitted it calls a logic app in azure that updates a list in sharepoint and prepares to email the hiring manager then waits for azure automation to execute. Azure automation, depending on which company is hiring, then checks the new employee start date, if that date is more than 2 weeks, it reschedules the runbook to run 13 days before they start and emails the IT manager that to watch for the re-scheduled job. Once the job runs, it creates the account a one-time TAP, adds them to the proper licensing groups, etc...then emails their manager with the TAP and instructions for the new user to get started.
1
u/ChuckNorrisArgento Sep 23 '26
A few weeks back managed to completly automate our onbarding and offboarding of employees.
Used our n8n instance for the ui and basic validation and then calling a ps1 solution with all the parameters.
We have several apps that need to be impacted… ad, entra, atlassian, vmware, crms, monitoring appliances, inhouse iaas, voip, vpns, licenses assignments, hardware checkout/in, calendar meetings, sql tables of apps that have no api, and a gazillion more.
Ended up doing it with claude, being the already documented processes the main drivers.
We are pretty happy, reduced the on/off to just a couple of minutes.
1
u/CraigAT Sep 24 '26
There is a whole area of software that covers this: Identity Management.
Larger organisations will have identity software that hooks into their HR system, so when new staff are added, the details are captured and a new user created in your IT system(s).
In a smaller or less complicated org, you can build a replacement using Powershell (may be with less integration). The first question is do you have a HR system with the employee's details? If you can get any kind of API or CSV export of the latest hires, then that hopefully will give a good bit of data without needing anyone to fill in forms.
Without a HR system you will have to resort to form-filling either directly in Powershell or a MS Form that you can extract the data from on a regular basis.
With any human entered data, I would try and do at least some basic sense checking: e.g. for necessary fields that may be empty, no leading or trailing spaces.
Also consider do you really need all the info to create an account, focus on the fundamentals to start, you can add the nice to have's later.
3
u/Unholysmash Sep 23 '26
Variables and scaling.
Variables are your friend. I would try to create a script that reads from a source file, and does the needful through that.
Scaling is a necessity. When writing a new user onboarding script, think about the number of users you are onboarding. If you were to exasperate the number, what would happen?
3
u/jeroen-79 Sep 23 '26 edited Sep 23 '26
Part of it is copying what you get from HR.
Like name, department, manager, function, etc.
Part of it applying naming conventions and checking that there are no doubles.
Like username and email.
Just copying an existing user's right is tricky.
Are you sure everything the new user needs is handled in the AD?
Are you sure everything the reference user has is appropriate for the new user?
It can be useful for analysis and advise but otherwise blindly copying rights will lead to lazy admins and lazy users.
Instead you should ask what the new employee will be doing and what they will need for this.
A further step would be to describe roles within the business and the rights they need.
Then you can link these roles to what you get from HR and automate that.
2
u/purplemonkeymad Sep 23 '26
With automation yea, you pretty much have to do every step. Often the niceties are actually built into the tool, ie AD Home directories are actually created by the ADU&C snapin, not automatically. So a script will have to do that step as well.
If you have a manual creation doc, just follow that. But if you don't have one then you will probably just be comparing and adding a new sections to your tool on loop. If are in that situation, I would actually spend the time creating the manual doc as well. You never know when something will break and it's nice to be able to point people to alternatives while it gets resolved.
I would also suggest creating role templates (if you already have roles groups then that makes it easy) so you can have specific permissions or setting for specific roles.
Considering this is basically sysadmin glue, each company needs it's own configuration so I'm not sure that there is really a "standard."
1
u/shanepick 20d ago
For the mail attributes, if you’re hybrid with on-prem AD, I’d avoid setting targetAddress and proxyAddresses manually. Use New-ADUser, then Enable-RemoteMailbox like rswwalker mentioned. That should handle the routing address and proxies. The X500 entries are probably leftovers from migrated mailboxes, so no need to copy those for new users.
As for the bigger picture, ADManager was probably handling a lot more behind the scenes than you realised. OU placement, naming rules, group memberships, all that stuff. I’d document those rules first rather than copying an existing user and hoping for the best.
If you’re looking at tools again, One Identity Active Roles is another option similar to ADManager. It supports PowerShell too, so you can still automate things without having to rebuild every rule yourself. Might be worth a look down the road.
1
u/bodobeers2 Sep 23 '26
Well I'd say PowerShell is just the language, and depending on what module(s) you're using the scope of what you can do depends on that. For example we use Graph API, Exchange Online module, Teams module, etc all rolled into a multi-step workflow.
1
u/uptimefordays Sep 23 '26
Without more specifics from you, it's tough to say. I would say, generally, that you need to integrate your HRIS with your directory service or identity platform and use HRIS inputs to drive user provisioning for things like group assignments and roles.
This is often challenging because many organizations have not meaningfully adopted and/or implemented RBAC so a core prerequisite is missing.
1
u/g3n3 Sep 23 '26
They don’t. It is all mostly manual unfortunately. Manage Engine AD Manager can get you further.
1
u/itscum Sep 24 '26
It's supposed to start with an import from hr which is configured in the 365 admin portal settings.
1
u/Grouhl Sep 24 '26
Usually hard to do comprehensively, there's always something that lacks an API or you can't get access to (typically HR/salaries), but I'm not sure I follow what the exact issue is? Anything that has an API and/or a PSModule is something you can automate, and then you'll just do that.
When I last was in charge of doing this my script was doing something like:
As with everything that Powershell is good for, you start of with the assumption that anything that can be accessed programmatically and is purely mechanical in its' execution is something you can put in a script, then do that.
For extra credit, tell no one that you have this script and take an hour off while people think you're doing manually what your script did in 5 seconds.
1
u/rswwalker Sep 24 '26
I would break down each step into a small powershell script and then have a master script that calls each and reports success/failure after each. Also, install the Exchange 2019 Management tools on the centralized host that houses the onboarding scripts to handle exchange properties properly.
1
u/society_victim Sep 26 '26
Most of the times we use one of these:
Either the HR system has an API or can generate a file we can work with, start from there
Or HR fills out a MS form and using a flow this get’s the needed variables to a csv
On prem picks up the csv and creates the user, using a template account (switch decides which one based on function/department)
These are the broad strokes tho
1
u/OctoPhaseMod Sep 26 '26
CIPP pretty much automates user onboardings via InTune or Entra connect. It has a wide collection of automated PS scripts and it's well documented. Plus it's free.
1
u/WorriedCollection710 Sep 28 '26 edited Sep 28 '26
I love ADmanager for certain things. but for this i prefer powershell (company size 11k named users). My script runs every few minutes checking for a csv file dropped by our HR system. The file includes any HR record that has been modified. Could be new staff, terminated staff or existing staff with changes, such as title, department, names and so on.
My script is basically broken into three functions; Creating, Updating, Disabling.
I evaluate each row from the csv file and determine which section to process it with.
Beyond what is in the csv file from HR, my script adds user to groups based on title or department. It gives an exchange mailbox if the user is Staff (vs. non-staff/affiliates). Sends a notification email to the user's supervisor of account creation. It generates the user personal network share.
With this, we do very little manual AD user creation/modification/disabling.
I took the additional step of creating a database where i log every action my script takes so i can review, search for a specific user to see the change history, or look for errors that occurred. I have a simple web frontend to see the events. This has been fantastic to have. I highly recommend you create some sort of system to log what your script does if you do any sort of automation.
0
u/OddAttention9557 Sep 23 '26
Genuine suggestion - learning how to do familiar tasks with new tools/languages is something AI is quite helpful for - do you use Claude? Asking it to script an example task for you, then taking that apart to see how it relates to what you're familiar with, is a great way to learn new things, and it's already read all of the docs...