0/1 Lessons

Course Introduction

• 5min

0 / 2 lessons complete

Getting Started with Windows PowerShell

• 42min

0 / 7 lessons complete

Getting Help and Finding Commands

• 39min

0 / 6 lessons complete

PowerShell Command Syntax

• 33min

0 / 5 lessons complete

PowerShell Objects and Properties

• 35min

0 / 6 lessons complete

The PowerShell Pipeline

• 24min

0 / 2 lessons complete

PowerShell Providers

• 30min

0 / 5 lessons complete

PowerShell Arrays and Variables

• 28min

0 / 4 lessons complete

PowerShell Loops

• 19min

0 / 3 lessons complete

PowerShell Conditional Statements

• 11min

0 / 1 lessons complete

On Premises Lab Setup

• 36min

0 / 8 lessons complete

Basic Domain Administration with Windows PowerShell

• 2hr 27min

0 / 10 lessons complete

Send Emails with PowerShell

• 22min

0 / 2 lessons complete

PowerShell Desired State Configuration (DSC) Basics

• 1hr 48min

0 / 6 lessons complete

Course Conclusion

• 1min

0 / 1 lessons complete

Creating Organizational Units with Powershell

Saving Progress...

In this lecture, we are going to learn how to create Active Directory Organizational Units with Windows PowerShell.

Now, first just a quick reminder. The way you would do it using the Graphical User Interface is by clicking Tools here in the upper right-hand corner of Server Manager and selecting Active Directory Users and Computers.

Then we select the desired location and choose New > Organizational Unit.

And we make some kind of name like Test123 and you can uncheck Protect container from accidental deletion and click OK.

And there is our Organizational Unit Test123 and it has been created under instructorpaul.com.

So, we are going to learn how to do this in PowerShell.

I am going to go ahead and delete that Organizational Unit and launch PowerShell as Administrator.

Click Yes on the User Account Control window.

First, before we create the Organizational Unit let’s learn how to list or get our Organizational Units.

We are going to type Get-ADOrganizationalUnit and press Enter.

What it did right there is that it Imported the Active Directory module for us.

Now is asking us to type in a Filter. We are just going to type in a * and press Enter.

It has output every single Organizational Unit that it is inside of our Active Directory.

This is not a human-readable format or an easy-to-understand output since it is kind of split up. You can work with it if you wanted to but what we are going to do is format this in a table format with the command Get-ADOrganizationalUnit | Format-Table and choose what objects we want to include.

I am going to include the following Get-ADOrganizationalUnit | Format-Table Name, DistinguishedName, and press Enter. For the Filter, I will enter a * and press Enter.

Now, this is much easier to see the display of results.

So, one thing that we can also do to make our lives a little bit easier is to use the following command: Get-ADOrganizationalUnit -filter “*” | Format-Table Name, DistinguishedName and press Enter.

So, we are saying get every Organizational Unit immediately.

So, what we are doing is streamline and make it faster so we don’t have to enter the second input as at the command prompt.

Now, let’s talk about, how do you search for a specific Organizational Unit?

Let’s say for example, how do you find all the Organizational Units that are directly beneath the InstructorPaul Organizational Unit?

And, The way you can do that is by typing: Get-ADOrganizationalUnit -filter “*” -SearchBase “OU=InstructorPaul,DC=instructorpaul,DC=com” | Format-Table Name, DistinguishedName and press Enter.

This is going to list every Organizational Unit under InstructorPaul.

Now, it is important to keep in mind that this is getting every Organizational Unit under InstructorPaul and there’s a couple of nested OUs under this.

So, if I just want to grab the first level or every Organizational Unit that is directly beneath InstructorPaul I can do that by adding yet another argument like the following:  Get-ADOrganizationalUnit -filter “*” -SearchBase “OU=InstructorPaul,DC=instructorpaul,DC=com” -SearchScope OneLevel | Format-Table Name, DistinguishedName, and press Enter.

This gets the first level Organizational Units right under InstructorPaul.

Now, if I open Active Directory Users and Computers and expand instructorpaul.com > InstructorPaul I can see I have Domain Users, Domain Workstations, and member Servers.

And in this last PowerShell command prompt, I also have  Domain Users, Domain Workstations, and member Servers.

OK, let’s say we want to create a new Organizational Unit under the InstructorPaul OU.

You can do that by just simply typing New-ADOrganizationalUnit -Name “Test123” and pressing Enter.

Now, by default, it will go under the root of our directory so if I refresh the Active Directory Users and Computers I now have Test123 which was created a second ago.

Server Academy Members Only

Want to access this lesson? Just sign up for a free Server Academy account and you'll be on your way. Already have an account? Click the Sign Up Free button to get started..

0 0 votes
Lesson Rating
Notify of
Inline Feedbacks
View all comments