none
Inactive User 90 days and value in extensionAttribute2

    Question

  • Hello,

    I found the script to find the users accounts inactive 90 days, but I need to find with the accounts the attribute extensionAttribute2 no empty. but I don't know how use two filters :

    mport-module activedirectory  
    $domain = "domain name"  
    $DaysInactive = 90  
    $time = (Get-Date).Adddays(-($DaysInactive)) 
      
    # Get all AD User with lastLogonTimestamp less than our time and set to enable 
    Get-ADUser -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $true} -Properties LastLogonTimeStamp
    get-aduser -filter {extensionAttribute1 -notlike "*"} |
      
    # Output Name and lastLogonTimestamp into CSV  
    select-object Name,@{Name="Stamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd_hh:mm:ss')}},extensionattribute1 | export-csv OLD_User.csv -notypeinformation

    Thursday, March 16, 2017 3:19 PM

All replies

  • Hi puffydee,

    >>but I need to find with the accounts the attribute extensionAttribute2 no empty. but I don't know how use two filters :

    Change this line:

    get-aduser -filter {extensionAttribute1 -notlike "*"} |

    to:

    get-aduser -filter {extensionAttribute2 -notlike "*"} |

    Or:

    get-aduser -filter {extensionAttribute1 -notlike "*" -and extensionAttribute2 -notlike "*" } |

    -and or -or

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, March 17, 2017 3:39 AM
    Moderator