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

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of JasonL JasonL 2 weeks, 5 days ago.

  • Author
    Posts
  • #70162
    Profile photo of JasonL
    JasonL
    Participant

    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
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    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
    Profile photo of JasonL
    JasonL
    Participant

    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"....so reports are the same...but I can see the disabled accounts in A/D user OU???

  • #70174
    Profile photo of JasonL
    JasonL
    Participant

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

You must be logged in to reply to this topic.