help - A/D report for 'enabled accounts not reporting true....

This topic contains 3 replies, has 2 voices, and was last updated by  JasonL 1 year ago.

  • Author
  • #70162


    Hi, I have a script that queries the A/D for accounts that are enabled:

    Get-ADUser -SearchBase 'OU=Users,OU=XXXXX,DC=XXXXX,DC=co,DC=uk' -filter {enabled -eq "True"} | Select-Object Name,SamAccountName | Sort-Object Name | Select -Property Name,SamAccountName | Out-file -file "C:\Active Directory\Active Users.txt"

    Which appears to work, but on further inspection, I have found that it is listing a few odd 'disabled' accounts (verified in A/D)...I even tried {enabled -eq "False"} to try and report the disabled accounts, but it misses them???

    Help much appreciated

  • #70168

    Rob Simmers

    Try comparing the value on the boolean $true versus a string "True"

    Get-ADUser -SearchBase 'OU=Users,OU=XXXXX,DC=XXXXX,DC=co,DC=uk' -filter {Enabled -eq $true} | 
    Select-Object Name,SamAccountName | 
    Sort-Object Name | 
    Out-file -file "C:\Active Directory\Active Users.txt"
  • #70171


    Thanks for the quick response Rob!

    I did try that too – and for some reason that returned the same output – I also tried $False in reverse to get disabled accounts and that also returned the same as -eq "False" reports are the same...but I can see the disabled accounts in A/D user OU???

  • #70174


    sorry everyone, I forgot to format the code too here!

You must be logged in to reply to this topic.