My Technet Gallery Scripts

It is not because I am not blogging that I am not busy :)

In the last months I have published several scripts to the Microsoft Technet gallery, that I want to summarize in this post:

1. Find Broken Inheritance in a SharePoint 2010 web application

This powershell script allows for enumeration through a SharePoint 2010 web application to identify all sites, document libraries, lists, folders and items for which the permission inheritance has been broken.

This script should be executed using a SharePoint 2010 Management Shell on one of the SharePoint servers in the farm with an account allowed to access all content.

2. Reset Broken inheritance in SharePoint 2010 site collection

this PowerShell script allows for resetting broken inheritance within a site collection. It will run through all subsites, lists, document libraries, folders and individual items, check if permission inheritance is broken and reset the inheritance.

3. Populate PictureUrl with values from CSV file

This PowerShell script allows you to populate the PictureUrl property of the User Profiles in SharePoint 2010 based on a provided CSV file, containing the username and the picture URL.

4. SharePoint document versions report

This script will generate a tab delimited text file with all the documents present is in the given web application in SharePoint 2010. It will list the documents, the size of the document, the number of versions, the sie of the versions and the total size. This report will enable you to identify large files throughout an entire web application and identify those files that have many versions and are basically eating up all your storage.

5. Find Connected Web Parts in Web application

This script locates all pages in an entire web application that uses connected web parts. the script runs through all the aspx pages in all document libraries of all sites in every site collection and checks if there are web part connections defined. If this is the case it will list the page and the provider and consumer web part title.

The script can easily be adapted to find specific web parts in an entire web application

6. Sync SharePoint 2010 User Profile PictureUrl attribute with AD attribute

This Powershell script allows you to synchronize an Active Directory custom attribute with the SharePoint 2010 user profile service application PictureUrl property. Usefull for companies that store picture url information in a custom attribute and want to replicate that information into SharePoint 2010. Normally this should be feasible by customizing the ForeFront Identity Manager used by the SharePoint 2010 User Profile Synchronization service, but this is not supported. The script can be easily customized to use a different extension attribute in Active Directory

Use this script in combination with a scheduled task on one of the SharePoint servers in the farm.

7. Find Web parts in SharePoint farm

he following powershell script will allow you to identify site collections where a given webpart is used. Very usefull during migrations when you have identified the web parts that cannot be upgraded and need to know where they are used. The script allows you to specify a scope of webapp or site collection to go through and look into the web part gallery to check if the web part is present.
Prerequisites for this script is having Powershell 2.0 deployed on the SharePoint 2007 server.
This post describes the implementation of rule based Active Directory groups (RBAG’s), maintained by a custom PowerShell script. The need for such rule based groups can vary. For example maintaining an Active Directory group that holds all members of a specific department can be challenging when no identity management system is available in the company. Hence the creation of this PowerShell script. The script allows for updating Active Directory groups based on a LDAP filter configured on specific Active Directory Groups.

2 thoughts on “My Technet Gallery Scripts

  1. Hi Dirk,

    Great script. I have been trying to tweak it a little so I can set the -SearchBase and limit which OU’s are searched in AD with little success. Is this something you could help out with?

    I have tried to add it to the notes field in AD which would give super granularity and control. I think the ” or ‘ are being added which is causing the script to fail.

    Thanks kindly

    David

    • Hi,

      for you to be able to include the searchbase in the query, you could change the script to read the searchbase form the notes field as well.

      The notes field could look like:
      Filter:(&(ObjectClass=Person)(Department=Management))
      SearchBase:OU=Mgmt,OU=CorpUsers,DC=contoso,DC=com

      Then you need to change the script as follows:

      Replace:
      $filter = $group.info
      Replace By
      $filter = ""
      $searchbase = ""
      $notesField = $group.info
      $strArray = $notesField.Split("`r`n")
      foreach($strField in $strArray)
      {
      if ($strField.ToLower().StartsWith('filter:') -eq $true)
      {
      $filter = $strField.ToLower().TrimStart('filter:')
      }
      if ($strField.ToLower().StartsWith('searchbase:') -eq $true)
      {
      $searchbase = $strField.ToLower().TrimStart('searchbase:')
      }
      }

      Replace:
      $NewGroupMembers = Get-ADObject -LDAPfilter $filter | Sort-Object distinguishedName

      Replace By:
      if ($searchbase -eq "")
      {
      $NewGroupMembers = Get-ADObject -LDAPfilter $filter | Sort-Object distinguishedName
      }
      else
      {
      $NewGroupMembers = Get-ADObject -LDAPfilter $filter -SearchBase $searchbase| Sort-Object distinguishedName
      }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>