Identify Inactive GTS Online user accounts Follow


Customers don't always notify GTS when a user account is no longer used or when they stop using GTS Online all together.  The following document will show how to use a PowerShell script to identify user accounts that have been inactive for three months or more.


PowerShell Script

  • Log on to one of the GTS Online active directory servers.
  • Click on START > Administrative Tools
  • Right-click on Active Directory Module for Windows PowerShell, and select Run as administrator
  • Click Yes on the User Account Control screen to authorize access
  • Copy/Paste the following script into the PowerShell window:

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

  • Verify that it is being read as a single line of code, and not multiple lines
  • Once the script has run, it will export a CSV file name InactiveUsers.csv to the C:\Powershell_Export folder
  • Copy that file to your local PC, and open it in Microsoft Excel
  • The file contains the following columns:
  1. Name - The customer's name or account id
  2. SamAccountName - This is the account id that the customer uses to log on to their server
  3. LastLogonDate - Lists the last date/time that the customer logged on to their server
  4. DistinguishedName - The Active Directory path where the user account is located
Have more questions? Submit a request


Powered by Zendesk