Skip to content

Instantly share code, notes, and snippets.

@amnich
Created August 7, 2017 07:35
Show Gist options
  • Save amnich/5e2ae590f3a7a65d0ac8899273557f9d to your computer and use it in GitHub Desktop.
Save amnich/5e2ae590f3a7a65d0ac8899273557f9d to your computer and use it in GitHub Desktop.
$user = Get-ADUser TestUser -Properties *
$props = $user.psobject.properties.name
$users = Get-ADUser User1
# or test all AD Users
# $users = Get-ADUser -Filter *
foreach ($user in $users){
try {
$User | Get-ADUser -Properties * | Out-Null
}
catch{
Write-Output $user.SamAccountName
foreach ($prop in $props){
try {
$user | Get-ADUser -Properties $prop | Out-Null
}
catch{
Write-Output " $prop"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment