Get OU Included in SharePoint User Profile Synchronization Configurations


This TechNet Wiki is to share PowerShell Snippet which retrieves Included OU in SharePoint 2010 User Profile Synchronization. Ensure you are farm admin while executing the script. Please do read the code and execute in acceptance and then in Production.


This morning we received some email alerts “Your Mysite is marked for deletion”. Indeed user ID is not disabled but moved from one OU to other OU So what’s wrong in it. Nothing much if your SharePoint 2010 UP SYNC Connections has all the OU’s. If not it’s a challenge. You can review more articles in web. We started analyzing the issue – Technically each and every SP admin had different opinion.


Hey SP Admins get me the Included OU list in SharePoint UPS SYNC. Follow the below process

  1. Disable MySite Clean Up Timer Job.
  2. Edit Sync settings.
  3. Drill down the Forest and get me the OU names.


Above steps are easy to draft as solution document but it’s huge work for SP Admins (Indeed I am part of SP Admin Team). Running Mysite clean up job manually will become an operational task. We do have one step solution – Open SharePoint Shell Management and execute the below code


Validate SharePoint 2010 List Fields Using PowerShell

One of my client requested for validating the list fields. The list is deployed as part of custom solutions. There is no big challenge doing it by inserting validation formula. However I took a quick look of PowerShell property to achieve the same.

List Available in SharePoint 2010


Where Title is set to 255 and Age is a Number Data Type accepts range between 18 and 30. We can do this in GUI as well. Let’s see the code in PowerShell


Avoid Accidental Deletion of SharePoint List

One of my client requested a settings in SharePoint 2010 to avoid accidental deletion of Lists.
Indeed we can recover it from Recycle Bin within 30 days, but they need to avoid deletion. Alternatively we can make a permission settings to avoid deletion.

Let’s see how to do this using PowerShell.


AllowDeletion is a Property which will allow us to set and get.


Reference Class

SharePoint 2010 : Query SharePoint List Items missing required fields.

In most of the organizations Content Managers decides the fields and its property for the List or Library. They are Power Users and have certain limitations to fetch reports.

We started discussing about Power Query and ended up in PowerShell.

Need to fetch Document Library Items which miss some required fields.

We all know that SharePoint will not allow us to submit the item if we miss the required fields. However in some cases content managers might have changed the settings and revert. During this interval we may have few items created with no required fields.