none
Script to query active machines and active users in active directory RRS feed

  • Question

  • Hi there, 

    First of all, I am not a technician, I am a Software Asset Management consultant helping companies to properly license the software they are using but in order to do that, I need a good in-depth overview of their infrastructure.  Some of the SAM tools that my customers use cannot get the following data out of the AD and I am therefore looking for a simple powershell script they can run against their AD. I need a script that gives the following parameters: 

    • Machine name or computer name
    • Operating system
    • Last actvity date/last logon or last heartbeat or another parameter that shows if the machine is still active
    • the full OU label

    I also need a script to get the following information out of AD: 

    • User name
    • Activity state/last logon or a similar parameters that shows the activity of the account
    • Disabled account?
    • full OU label

    I would be foreever greatful!

    Lieve Geelen

    SAM Consultant



    • Edited by Lieve Geelen Thursday, November 20, 2014 12:05 PM
    Thursday, November 20, 2014 12:04 PM

Answers

  • For the machines

    get-adcomputer -filter * -Properties Name,OperatingSystem,LastLogonDate,DistinguishedName | Select Name,OperatingSystem,LastLogonDate,DistinguishedName

    For users

    get-aduser -filter * -Properties Name,LastLogonDate,DistinguishedName,Enabled | Select Name,LastLogonDate,DistinguishedName,Enabled

    Note, lastlogondate isn't entirely accurate but it should be good enough.
    Thursday, November 20, 2014 12:10 PM

All replies

  • For the machines

    get-adcomputer -filter * -Properties Name,OperatingSystem,LastLogonDate,DistinguishedName | Select Name,OperatingSystem,LastLogonDate,DistinguishedName

    For users

    get-aduser -filter * -Properties Name,LastLogonDate,DistinguishedName,Enabled | Select Name,LastLogonDate,DistinguishedName,Enabled

    Note, lastlogondate isn't entirely accurate but it should be good enough.
    Thursday, November 20, 2014 12:10 PM
  • thanks a million!

    Lieve Geelen

    Friday, November 21, 2014 11:28 AM