How to find the list of all disabled/inactive users in the last 30 days using a web.ensureuser method in powershell

Question

Wednesday, March 8, 2017 7:05 PM

Hi All,

I am faced with a challenge of getting the list of inactive/disabled sharepoint users from the active directory in my sharepoint environment using we.ensureuser command in powershell. I was told not to use the get-ADuser command.

To enable me using the ensureuser command, the following prerequisite is being carried on in the SQL server:

1.List of User IDs that have been deactivated/disabled in the active directory

2. Employee's manager information eg, ID

3. Date when the User ID was deactivated/disabled in the Active Directory

4. A list will be created in a site collection for with fields for listing the inactive users, their managers id, date etc etc.

My task is to  query the sql/sharepoint using the ensureuser command and populate the list above with the inactive users and their manager's ID. 

I will use any available help.

Cheers!

All replies (5)

Wednesday, March 8, 2017 7:51 PM ✅Answered

Which is just a more complicated way of using Get-ADUser.

Trevor Seward

Office Servers and Services MVP

Author, Deploying SharePoint 2016

This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.


Wednesday, March 8, 2017 7:18 PM | 1 vote

SharePoint doesn't store any information about user's Active Directory status. You must use LDAP calls to determine the status of the account (specifically looking at userAccountControl for active status). Get-ADUser is the proper method, from an easy PowerShell perspective, to accomplish this.

I'd suggest revisiting this with those making the request.

Trevor Seward

Office Servers and Services MVP

Author, Deploying SharePoint 2016

This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.


Wednesday, March 8, 2017 7:48 PM | 1 vote

Hi,

Here you go

https://www.petri.com/find-disabled-and-inactive-active-directory-users-accounts-with-powershell-revisited

Please remember to click Mark as Answer on the answer if it helps you


Wednesday, March 8, 2017 8:49 PM

Sure Sir!!


Thursday, March 9, 2017 8:31 AM

Hi intheone,

If the reply is helpful to you, you could mark the reply as answer. Thanks for your understanding.

Best regards,

Sara Fan

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com