Options
AD Powershell Command
Ok, here's what I'm trying to do. I'm attempting to pull a list of all disabled users from AD. I've got the script working but I'm having issues trimming down exactly what I need.
Here's my script:
I'd like to trim this down to just show me the user ID. I don't care about the name because I'm going to be taking the user IDs and pumping them into another application. When I try to run this:
the command fails.
Any ideas? And, yes I'm doing this in PowerShell for a reason.
Here's my script:
Search-ADAccount -AccountDisabled -UsersOnly | FT Name,SamAccountName -A
I'd like to trim this down to just show me the user ID. I don't care about the name because I'm going to be taking the user IDs and pumping them into another application. When I try to run this:
Search-ADAccount -AccountDisabled -UsersOnly | SamAccountName -A
the command fails.
Any ideas? And, yes I'm doing this in PowerShell for a reason.
Comments
-
OptionsRTmarc Member Posts: 1,082 ■■■□□□□□□□Figured it out. Here is the code that works:
Seach-ADAccount -AccountDisabled -UsersOnly | Get-ADUser -Properties SamAccountName | Select SamAccountName | Sort-Object SamAccountName
If there is a more efficient way to do this command, I'm interested in hearing what you have. -
OptionsRobertKaucher Member Posts: 4,299 ■■■■■■■■■■Figured it out. Here is the code that works:
Seach-ADAccount -AccountDisabled -UsersOnly | Get-ADUser -Properties SamAccountName | Select SamAccountName | Sort-Object SamAccountName
If there is a more efficient way to do this command, I'm interested in hearing what you have.
Have you looked at the Quest Software AD Commandlets? These are from the same company that created the PowerGUI Script Editor.