Home
Windows
    Windows Server
    Windows Client OS
Linux
Powershell
Virtualization
    VMware
    Hyper-V
Cloud Computing
    Citrix XenApp
    Citrix Xendesktop
Useful links
About
ajni.IT -
  • Home
  • Windows
    • Windows Server
    • Windows Client OS
  • Linux
  • Powershell
  • Virtualization
    • VMware
    • Hyper-V
  • Cloud Computing
    • Citrix XenApp
    • Citrix Xendesktop
  • Useful links
  • About

Powershell: Getting Inactive AD Users

September 23, 2019 by AJNI No Comments

Hey folks!

Here is a quick way to find inactive AD Users in your environment. Get-ADUser ist the cmdlet we are going to use.

We are getting all users from the highest OU (domain.com) and using the Property LastLogonDate, which will not be returned if not specified in the -Properties parameter. After that a Where statement is going to show users that haven't logged in since 90 days or more.

Get-ADUser -Filter * -Properties lastlogondate | where { $_.lastlogondate -lt (Get-Date).AddDays(-90) }

We could also specify the OU where the command is going to search:

Get-ADUser -Filter * -Properties lastlogondate -SearchBase "OU=TerminatedEmployees,DC=Company,DC=com"| where { $_.lastlogondate -lt (Get-Date).AddDays(-90) }|select Name,Lastlogondate

There is also the -SearchScope Onelevel parameter to determine that we are not going to search recursively:

Get-ADUser -Filter * -Properties lastlogondate -SearchBase "OU=TerminatedEmployees,DC=Company, DC=com" -SearchScope OneLevel | where { $_.lastlogondate -lt (Get-Date).AddDays(-90) }|select Name,Lastlogondate

Have fun!

Reading time: 1 min

Get Locked Out Users in Active Directory (Powershell)

March 15, 2019 by AJNI No Comments

Hi Folks!

Here is a quick command to find locked out users in your domain. Pretty straightforward:

If that's too much Information you can only select the username:

The command is not getting recognized? Be sure to install the RSAT (Remote Server Administration Tools) for AD DS (Active Directory Domain Services), which also install the Powershell Snap-In via Server Manager (if you are using a Windows Server OS to manage your AD):

Alternatively you can download the RSAT for Windows 10.

Reading time: 1 min

Tip Of the Day

  • Delete or rename a folder with a blank space at the end

    1 month ago

Recent Posts

  • Microsoft AlwaysOn VPN Deployment
  • Delete or rename a folder with a blank space at the end
  • Automatic program start at logon with GPOs
  • Reset Computer Secure Channel of a Domain Computer with one PowerShell command
  • Let Outlook connect to Exchange Online instead of Exchange On-Prem

Categories

  • Azure (5)
  • Citrix XenApp (6)
  • Citrix Xendesktop (4)
  • Cloud Computing (18)
  • Coding (1)
  • Hyper-V (5)
  • Linux (8)
  • Powershell (8)
  • Security (2)
  • VDI (4)
  • Virtualization (12)
  • VMware (5)
  • Windows (16)
  • Windows Client OS (14)
  • Windows Server (23)

Archives

  • December 2020
  • November 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019

ajni IT © 2019