Get-ADUser Examples: How to Find AD Users with PowerShell

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video I'm going to show you the get 80 user command and how to use it to get active directory user accounts from your domain so I'll start off with a single account and then I'll show you how to get all users users from OU's and how to search the domain for specific accounts so to get a single user just do get 80 user and then the perimeter identity and then the account you want to get and you can use the Sam account to identify accounts you can use the same account distinguished name grids carry identifier I typically use the same account because that's usually the user's logo name so it's just easiest to to use that so there's the command I'll run that and you can see it's going to get some limited information back from active directory these are all the default properties which is may not be helpful um typically you'll want to get specific information like Department phone numbers email proxy addresses so to get the additional properties you'll want to use the properties perimeter and then the asterisk run this and then you can see it's getting a lot more information back from active directory and then to limit the results you can use a pipe and then select and then list whatever properties you want to display so let me change to a different account because my account doesn't have much information in it I'm going to use grab this user's logon name and then I'll run it for this other user and then I'm going to change I just want to see the name Department and the email address so let me clear this run it and now you can see it's just displaying the user's name department and email address and then you can just keep adding additional properties so I can add the state city and after you add I think it's yeah it looks like four one two three four after you add four properties that puts it in this different format which to me isn't very easy to read and you can change that by doing a pipe format table so now you can see I'm getting the single user and I'm getting the name Department mail State and address and again you can just keep on adding whatever properties you want um that's a single account so what if you want to get all users get all users you will use filter asterisk and this the single Command right here is going to go grab every single user from your domain and display the the default properties so I'll just stop it but you can see it's it's grabbing everything or not everything but every user and the default properties and to display all the properties for all the users you do the properties asterisk and you can see that's a lot of information so what you'll want to do is pipe select and I'll just start with name so now this is going to go grab it get every user from the domain and just display their name and again just keep adding whatever Department mail so now I'm getting every every user from the domain I'm going to display the name department and mail and there you go if I scroll up you'll see that the headers here the name Department mail so those are two very common just with those very few examples right there you should be able to get lots of information from your domain by a single user and then all users another common scenario is you know you want to limit that to an OU so to do that you'll need to get the distinguished name of that OU so to do that just come into active directory find the OU go to properties attribute editor and then find the distinguished name and then just copy that and then we'll use the search base perimeter and then put that distinguished name in quotes and when I run this it will get every user from my accounting OU and again if you want to change the output I'm going to add properties and then I'll do a select and I'll do name Apartments and email address and there you go so that's displaying all the users from my accounting OU and I'm displaying the name department and mail so what if you want to search there's all kinds of search operators you can do equal not equal to like not like Wild Card stuff but Let's do let's search the domain for all users with a specific first name so get 80 user wrong command so get any user filter and then the filter we're going to use you put your filter in the quotation marks so I'm going to I want to search by first name which that property is called given name I want it to equal and I want to equal mark if I run this you can see it's displayed all of the users with the first name Mark make this easier to read I'll do a select then I'll just do name there you can see it's displaying all of the users that just have the first name Mark if I wanted to search for all users with the last name just change your property here in your filter so I want to use last name which the property name is surname and if you want to find if you're confused on first name last name I've got a quick cheat sheet that shows you a visual of what these translate to with their properties and you can also come into the attribute editor and find them this way these are the actual attributes so come back and I'm going to do surname I'm going to change this to Smith so I want to find all users with the last name Smith and there you go all these users have the last name Smith so I'll do one more example and I'll link to an article that I've written that's got a bunch of examples let me show it to you here so you can literally just come to this article and copy and paste some of these examples and I got I've got a bunch of them so this last one I'm going to do I will search the entire domain find users that have a have a logon script set so you can see here this account has a batch file set as a logon script so I want to I want to know which accounts in my domain have a Locker on script configured so that command looks like this we're doing a filter and then we got our filter in the brackets here so I want to search for script path which is the logon script and then I want it to not equal null so that's saying I don't want the script path to be empty and then I'm going to display the name and the value of the script path so if I click run there you can see it's pulled back all of the user's name and then the logon script that they have configured so pretty easy it can go from easy to really hard there's you know just to find um you pull this up so to display you know all users that's a really simple command to display single users that's a really simple command but when you start messing around with filters it can get a little more complex but once you get the hang of it it's pretty simple to just do you know a filter and filter on a first name but you can you can really get a lot of useful information and find accounts in your domain which is which is some really simple filters but again you can start getting more complex and doing some really interesting Scripts so that's it for this video again I'll link to my article it's got more examples and that's it thanks for watching
Info
Channel: Active Directory Pro
Views: 11,741
Rating: undefined out of 5
Keywords: powershell, active directory
Id: ShoP0CMJ89o
Channel Id: undefined
Length: 10min 3sec (603 seconds)
Published: Wed Oct 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.