top of page
  • aldern00b

PowerShell and ADUser


Get-ADUser 

   [-AuthType <ADAuthType>] 

   [-Credential <PSCredential>] 

   -Filter <String> 

   [-Properties <String[]>] 

   [-ResultPageSize <Int32>] 

   [-ResultSetSize <Int32>] 

   [-SearchBase <String>] 

   [-SearchScope <ADSearchScope>] 

   [-Server <String>] 

   [<CommonParameters>] 

If you know the user and just want to see basic info

 Get-ADUser -Identity [USERNAME] 

If you know the user and want to see ALL info

 Get-ADUser -Identity [USERNAME] -Properties *  

If you don't know the full username and can search by last name

 Get-ADUser -Filter 'Surname -eq "[LAST NAME]"'  

Get all the users who have the job title of Piper then format the table by just showing the DisplayName

Get-ADUser -Filter 'Title -like "Piper*"' -Properties DisplayName | ft DisplayName 

Piper's who are currently enabled, showing only the found DisplayNames

Get-ADUser -Filter 'Title -like "Piper*" -and Enabled -eq "True"' -Properties DisplayName | ft DisplayName 

Disable a User

Disable-ADAccount -Confirm -Identity [USERNAME] 

Using an input file of usernames to disable large groups of users

 Get-Content C:\Users\username\Desktop\users.txt | ForEach-Object {Disable-ADAccount -Confirm -Identity $PSItem}  

Validate if a list of users (provided by a text file) are enabled

 Get-Content C:\Users\username\Desktop\users.txt | ForEach-Object {Get-ADUser -Identity $PSItem -Properties Enabled} | ft Name, Enabled  

Get all Pipers with their contact information

Get-ADUser -Filter 'Department -eq "Piper"' -Properties Name, Department, OfficePhone, MobilePhone | Sort-Object | ft Name, Department, OfficePhone, MobilePhone 

5 views0 comments

Recent Posts

See All

Comments


bottom of page