---
title: "Streamline Employee Onboarding with PowerShell: A Step-by-Step Guide"
description: "Discover a step-by-step guide on how to streamline employee onboarding using PowerShell and automate the process with a handy script."
canonical: "https://adamtheautomator.com/powershell-onboarding-script/"
---

# Streamline Employee Onboarding with PowerShell: A Step-by-Step Guide

> Discover a step-by-step guide on how to streamline employee onboarding using PowerShell and automate the process with a handy script.

Source: https://adamtheautomator.com/powershell-onboarding-script/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Streamline Employee Onboarding with PowerShell: A Step-by-Step Guide](https://adamtheautomator.com/wp-content/uploads/2019/06/automating-employee-onboarding-in-active-directory-active-directory-1.png)

# Streamline Employee Onboarding with PowerShell: A Step-by-Step Guide

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)16 June 20192 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Active Directory](/tag/active-directory/)[PowerShell](/tag/powershell/)

Employee onboarding is one of those tasks that is ripe for automation. A PowerShell onboarding script is a perfect tool for the job.

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

Onboarding is a task that’s performed hundreds of times that rarely changes. When hired, every employee needs an Active Directory user account, an email mailbox, access to this and that system, a home folder with specific permissions only to them and so on. A task that’s performed the same way multiple times is a perfect candidate for automation.

It seems like nearly every organization has Active Directory (AD). AD is a big part of employee onboarding that a lot of organizations may still be doing manually. The helpdesk is still opening Active Directory Users & Computers, right-clicking and creating a new user. They’re then manually adding that user to a specific set of groups and will ultimately screw it up do to all of their other responsibilities. Again, something automation can alleviate!

So you’re convinced automation is the way to go when onboarding new employee in AD, right? If so, how to do it?

One of the easiest ways to automate Active Directory tasks is with a PowerShell onboarding script. By using a freely available [PowerShell module](https://adamtheautomator.com/powershell-modules/ "PowerShell module"), you can create scripts to do just about anything with AD. For our purposes, we need to create a script to create a new user account for an employee and perhaps add her to a few common groups. To do this, grab a copy of [Remote Server Administration Tools](https://www.microsoft.com/en-us/download/details.aspx?id=45520). This will give you the ActiveDirectory PowerShell module. Once you do this, ensure you’re on a domain-joined computer and you have the appropriate rights to create new users.

In the ActiveDirectory PowerShell module, you have a command called [`New-AdUser`](https://adamtheautomator.com/new-aduser/ "New-AdUser"). There are lots of ways to use this command but below is a common way. In this PowerShell code, I’m generating a [random password](https://adamtheautomator.com/random-password-generator/ "random password") and then using it along with a first name, last name and username to create a new AD user. That’s it! No mouse clicking involved.

Related:[New-ADUser: Creating Active Directory Users with PowerShell](https://adamtheautomator.com/new-aduser/)

```powershell
Add-Type -AssemblyName System.Web
$password = [System.Web.Security.Membership]::GeneratePassword((Get-Random -Minimum 20 -Maximum 32), 3)
$secPw = ConvertTo-SecureString -String $password -AsPlainText -Force

$NewUserParameters = @{
	GivenName = 'Adam'
	Surname = 'Bertram'
	Name = 'abertram'
	AccountPassword = $secPw
}
New-AdUser @NewUserParameters
```

We also have a command called `Add-AdGroupMember`. This will add the user that was just created to a group.

```powershell
Add-AdGroupMember -Identity 'Accounting' -Members 'abertram'
```

One the great things about automation employee onboarding with PowerShell is that once the code is built, it can be ran for one, ten or a hundred employees with no extra effort. For example, perhaps I have a ton of new employees I need to provision in AD. By using the [`Import-Csv`](https://adamtheautomator.com/import-csv/ "Import-Csv") command, I can read each row in that CSV file and run the code we just went over.

This example is assuming you have a CSV with the columns FirstName and LastName.

```powershell
Add-Type -AssemblyName System.Web
Import-Csv -Path C:\Employees.csv | foreach {
    $password = [System.Web.Security.Membership]::GeneratePassword((Get-Random -Minimum 20 -Maximum 32), 3)
    $secPw = ConvertTo-SecureString -String $password -AsPlainText -Force

	$userName = '{0}{1}' -f $_.FirstName.Substring(0,1),$_.LastName
	$NewUserParameters = @{
		GivenName = $_.FirstName
		Surname = $_.LastName
		Name = $userName
		AccountPassword = $secPw
	}
	New-AdUser @NewUserParameters
	Add-AdGroupMember -Identity 'Accounting' -Members $userName
}
```

We just scratched the surface here to what’s possible to automate employee onboarding in Active Directory. If your organization has a predefined process with specific rules that have to be followed, this code could be just the beginniing of a much larger employee onboarding process that can be 100% automated!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-onboarding-script%2F&text=Streamline%20Employee%20Onboarding%20with%20PowerShell%3A%20A%20Step-by-Step%20Guide)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-onboarding-script%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-onboarding-script%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2024/11/image-23.png)

### [Managing Active Directory Groups with PowerShell: The Ultimate Guide](/powershell-ad-groups-guide/)

Learn how to manage Active Directory groups with PowerShell! This hands-on guide shows you how to query, create and modify AD groups using practical real-world

![](https://adamtheautomator.com/wp-content/uploads/2019/08/database-152091_1280.png)

### [Active Directory Database: PowerShell Monitoring Made Easy](/active-directory-database/)

Find the ntds.dit location and monitor your Active Directory database using PowerShell.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/panic-1393619_1280.png)

### [How to Find Locked Out Users in Active Directory with PowerShell](/find-locked-out-users-in-active-directory-powershell/)

See what we can do to find locked out users in Active Directory with PowerShell!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
