none
Find inactive computer accounts in a OU using powershell RRS feed

  • Question

  • Hi,

    I need to find inactive computer accounts in a particular OU. Is there any powershell script. I have the below script but it is saying me if the machine is disabled or enabled but not giving the number of days the machines are inactive.

    $COMPAREDATE=GET-DATE  
    #  
    # Number of Days to check back.     
    $NumberDays=60
    #  
    # Organizational Unit to search  
    $OU='GIVE DN of the OU'
    # OU (FQDN) value above masked for security
    #  
    GET-QADComputer -SizeLimit 0 -SearchRoot $OU |  
    where {($_.InactiveFor -le (get-date).adddays(-$NumberDays)) -and ($_.ParentContainer -notmatch "$OU/Privileged")} |  
    select Name, ParentContainer, Department, Office, Description, InactiveFor, LastLogon, AccountIsDisabled |
    Export-Csv C:\stale\file.csv -noTypeInformation 

    Thanks,


    Friday, June 7, 2013 6:22 AM

All replies

  • Hi,
    You hit the wrong forum with your question. Here we discuss Exchange Server and if you want help with Quests PowerShell Cmdlets, you should ask in their forum.

    Anyway...

    You could use the ActiveDirectory Powershell Module built-in to W2K8/W2k12 to find the information you are looking for .


    Example:
    Search-ADaccount -AccountInactive -Timespan 60:00:00:00 -ComputersOnly | ft Name,lastlogondate,enabled

    ...but this is not the right forum for this. Windows Powershell Forum is a better choice.

    Martina Miskovic

    Friday, June 7, 2013 6:44 AM