Inactive Sharepoint users - Sharepoint on-premise

unknown_25 21 Reputation points
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.

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,221 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,625 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,668 questions
SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
508 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,799 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 21,446 Reputation points Microsoft Vendor
    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.