Reviewing inactive GTS Online users Follow

The script below must be run from the “Active Directory Module for Windows PowerShell”. This application is located on the Administrative Tools menu of any of the online Active Directory servers.


The Active Directory server must have a folder named “PowerShell_Export” on the root of the C:\ drive.

When running the script, you should copy the script to a text editor and verify that it is a continuous string, and has no line breaks.

How it works

Paste the script into the PowerShell application, and it will collect and export a file named Inactiveusers.csv to the PowerShell_Export folder. This file can be opened in Excel once the file has been copied to your computer.


Search-ADAccount -AccountInactive -datetime (get-date).AddMonths(-3) -usersonly | ? {$.DistinguishedName -notlike "*ou=Disabled Accounts - Holding,*" -and $.DistinguishedName -notlike "ou=01Test_Users," -and $.DistinguishedName -notlike "*ou=Service Accounts,*" -and $.DistinguishedName -notlike "cn=Builtin," -and $.SamAccountName -notlike "lxattach.*" -and $.SamAccountName -notlike "admin." -and $_.SamAccountName -notlike "lynx." -and $.SamAccountName -notlike "QBE*" -and $.Name -notlike "RDX*"} | select Name,SamAccountName,LastLogonDate, DistinguishedName | sort name | Export-CSV -Path C:\Powershell_Export\Inactiveusers.csv

Have more questions? Submit a request


Powered by Zendesk