Inactive Sharepoint users - Sharepoint on-premise

2023-03-22T16:54:52.0566667+00:00

We need inactive Sharepoint users list for each site in Sharepoint on-premise. Is possible to get inactive users based on last visited date or last accessed date of the user? If it is possible, explain it in detail.

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,601 Reputation points Microsoft External Staff
    2023-03-23T07:16:37.6466667+00:00

    Hi @Manikandan Sankar ,

    You can get Inactive users in AD based on the last login time using PowerShell.

    # import module ServerManager
    Import-Module ServerManager
    
    # install RSAT
    Install-WindowsFeature -Name "RSAT-AD-PowerShell" -IncludeAllSubFeature
    
    # import ActiveDirectory Module
    Import-Module ActiveDirectory
    
    # set the date (the number of days)
    $NumberOfDays = 30
    
    # set the timeframe ranging for the amount of days entered
    
    $TimeRange = (Get-Date).Adddays(-($NumberOfDay))
    
    # checks for inactive users within 30 days timeframe
    Get-ADUser -Filter {LastLogonTimeStamp -lt $TimeRange } -Properties * | Select Name, LastLogonDate | Export-Csv InactiveActiveDirectoryUsers.csv -NoTypeInformation
    
    

    You can set the NumberOfDays you want.

    For more information, please refer to:

    https://learn.microsoft.com/en-us/services-hub/health/remediation-steps-ad/regularly-check-for-and-remove-inactive-user-accounts-in-active-directory

    https://cloudinfrastructureservices.co.uk/find-inactive-users-in-active-directory-using-powershell-script/

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.