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.

Microsoft SharePoint 2010 Administration Toolkit v1.0 released

Found this toolkit while scanvenging the new downloads on th MS Download site.

Beware of the final line on the download page:  This tool is not supported for SharePoint Foundation 2010.

Microsoft SharePoint 2010 Administration Toolkit v1.0

Brief Description:

The Microsoft® SharePoint® 2010 Administration Toolkit contains functionality to help administer and manage Microsoft® SharePoint® Foundation 2010 and Microsoft® SharePoint® Server 2010.

Overview:

The Microsoft SharePoint Administration Toolkit contains the following tools to help manage SharePoint Foundation 2010 and SharePoint Server 2010:

  • Security Configuration Wizard (SCW) manifests, which add roles for SharePoint 2010 Products to Windows Server 2008 with Service Pack 2 or to Windows Server 2008 R2.

    SCW is an attack surface reduction tool introduced with Windows Server 2003 Service Pack 1. SCW uses a roles-based metaphor to solicit the functionality required for a server and disables the functionality that is not required. By automating this security best practice, SCW helps to create Windows environments that are less susceptible, on the whole, to security vulnerabilities that have been exploited. For more information about SCW in Windows Server 2008, see Security Configuration Wizard (http://go.microsoft.com/fwlink/?LinkId=185511).

  • Load Testing Toolkit (LTK), which generates a Visual Studio Team System 2008 (VSTS) load test based on Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007 IIS logs. The VSTS load test can be used to generate synthetic load against SharePoint Foundation 2010 or SharePoint Server 2010 as part of a capacity planning exercise or a pre-upgrade stress test.

    To install the Visual Studio Team System (VSTS), see Visual Studio Team System 2008 Team Suite (http://go.microsoft.com/fwlink/?LinkID=101641). To install Service Pack 1, see Microsoft Visual Studio 2008 Service Pack 1 (http://go.microsoft.com/fwlink/?LinkID=116488).

  • User Profile Replication Engine 2010 (UPRE2010), which provides a shared services administrator the ability to replicate user profiles and social data between shared services providers (SSP) in Office SharePoint Server 2007 and User Profile service applications in SharePoint Server 2010. This Windows PowerShell-based tool is not supported for SharePoint Foundation 2010.
  • Content Management Interoperability Services (CMIS) connector for SharePoint Server 2010

    The Content Management Interoperability Services (CMIS) connector for SharePoint Server 2010 enables SharePoint users to interact with content stored in any repository that has implemented the CMIS standard, as well as making SharePoint 2010 content available to any application that has implemented the CMIS standard.

    The CMIS connector for SharePoint Server 2010 includes two features:

    • The Content Management Interoperability Services (CMIS) Consumer Web Part, which can be added to any SharePoint page. This Web Part displays and lets users interact with the contents of any CMIS repository.
    • The Content Management Interoperability Services (CMIS) Producer, which allows applications to interact with SharePoint lists and document libraries programmatically by means of the interfaces defined in the CMIS standard.


For more information about the Content Management Interoperability Services (CMIS) standard, see
OASIS Content Management Interoperability Services (CMIS) TC (http://go.microsoft.com/fwlink/?LinkId=196694).

This tool is not supported for SharePoint Foundation 2010.

MOSS Auto-Install at Codeplex

I was once again installing a test machine from scratch with MOSS and while I was waiting for the setrup to complete, I wondered if anyone had come up yest with a fully automated install and configuration script. Well actually there is a set of scripts that can be found on Codeplex.

MOSS 2007 Automated Installation scripts

Project Description
This project is a set of CMD/BAT and PowerShell scripts which together provide a quick and near-unattended installation and initial config (SSP, MySites) of Microsoft Office SharePoint Server 2007.
Works on Windows 2003/2008, both x86 and x64 platforms.

This set of batch scripts is based on (but significantly extends) the scripts originally found in the Office SharePoint Server 2007 farm automated setup Codeplex project.

No more hunting around for your ‘latest’ MOSS installation doc/guidelines, squinting over screen captures, or worrying about whether so-and-so remembered to select that option while entering that username on that particular screen – all now merely relics of The Dark Age of MOSS Installations.

The scripts will:

  • Check whether the target server is running Windows 2003 or 2008, and whether the platform is x86 or x64
  • Prompt you to start at a specific point in the process, or simply run the entire script. Useful for 2nd, 3rd etc. servers in the farm, or subsequent attempts
  • Prompt you to enter all service account passwords (should you choose not to specify them in the script, for security reasons)
  • Automatically install platform-specific pre-requisites (e.g. IIS, .Net Framework)
  • Disable some unnecessary Windows services (configurable by editing DisableUnneededServices.ps1)
  • Install the MOSS build binaries with no user input
  • Run the SharePoint Products and Technologies Configuation Wizard (psconfig.exe) in order to create the Farm (Config/Central Admin content databases, Central Admin site, help collections, etc.) – no user input
  • Configure and start SharePoint services (WSS Search, MOSS Search, Excel Services) – no user input
  • Create/configure your SSP and My Sites web apps, and create the SSP – again, no user input
  • Create the main Portal – you guessed it, no user input
  • Restart IIS, and launch IE to view the results of your hard work (just in time for your return from lunch)
  • Log all of this to %TEMP% and pop open the log file for review, when finished.

How To Recover Your SharePoint 2007 Product ID by Bert Johnson

On my post about the SP2 bug, I had a comment by Bert Johnson about a post of his explaining how to recover the SharePoint 2007 Product ID from your system. This is indeed very handy if you do not happen to have it or find it anymore and do not want to bother your customer for it loosing face (again [:D])

Bert wrote a vbs script that decodes the Product ID from the registry key blob data where it resides.

Thanks Bert for sharing this information, which will probably help a lot of us out there.

Subscribe to Bert’s blog with this Feed: http://blogs.pointbridge.com/Blogs/johnson_bert/_layouts/listfeed.aspx?List={071A5AE9-9B1F-44E7-8AF7-C0BC07CF531D}

The original post can be found at http://blogs.pointbridge.com/Blogs/johnson_bert/Pages/Post.aspx?_ID=10 .

Here is the script :

' Extract MOSS 2007 Product ID
' Written by Bert Johnson (PointBridge)
' http://blogs.pointbridge.com/Blogs/johnson_bert/Pages/Post.aspx?_ID=10

Const HKEY_LOCAL_MACHINE = &H80000002
Set reg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

wscript.echo GetKey("SOFTWARE\Microsoft\Office\12.0\Registration\{90120000-110D-0000-0000-0000000FF1CE}", "DigitalProductId")

Public Function GetKey(path, key)
    Dim chars(24), prodid
    Dim productkey(14)

    reg.GetBinaryValue HKEY_LOCAL_MACHINE, path, key, prodid
    
    For ib = 52 To 66
        productkey(ib - 52) = prodid(ib)
    Next

    'Possible characters in the Product ID:
    chars(0) = Asc("B")
    chars(1) = Asc("C")
    chars(2) = Asc("D")
    chars(3) = Asc("F")
    chars(4) = Asc("G")
    chars(5) = Asc("H")
    chars(6) = Asc("J")
    chars(7) = Asc("K")
    chars(8) = Asc("M")
    chars(9) = Asc("P")
    chars(10) = Asc("Q")
    chars(11) = Asc("R")
    chars(12) = Asc("T")
    chars(13) = Asc("V")
    chars(14) = Asc("W")
    chars(15) = Asc("X")
    chars(16) = Asc("Y")
    chars(17) = Asc("2")
    chars(18) = Asc("3")
    chars(19) = Asc("4")
    chars(20) = Asc("6")
    chars(21) = Asc("7")
    chars(22) = Asc("8")
    chars(23) = Asc("9")

    For ib = 24 To 0 Step -1
        n = 0

        For ikb = 14 To 0 Step -1
            n = n * 256 Xor productkey(ikb)
            productkey(ikb) = Int(n / 24)
            n = n Mod 24
        Next

        sCDKey = Chr(chars(n)) & sCDKey
        If ib Mod 5 = 0 And ib <> 0 Then sCDKey = "-" & sCDKey
    Next

    GetKey = sCDKey
End Function
Simply save that to a file named “ExtractMOSS2007ProductID.vbs” and run it to recover your key.  Once recovered, re-apply your Product ID through Central Admin, as outlined in KB971620.

Codeplex SPIEFolder

Pfff, it’s been a while again since my last post. I promise you guys that I will have some time soon to write more. Anyway…

This post to write about a cool tool that my colleague Pascal Rocheteau found today: SPIEFolder from codeplex.

Project Description
Allows you to either Import a file system folder (And all files and subfolders) into a SharePoint Document Library, and also export a SharePoint Document Library to the file system for
WSS 2.0/SPS2003 or WSS 3.0/MOSS 2007. This tool completely replicates the document libraries folder hierarchy to the file system when exporting, and replicates the folder hierarchy from the file system to the document library when importing.

Sounds really cool and usefull. Thanks Pascal for this

 

SWAT 2007

This is another one of those tools you should have on your SharePoint farm(s). Although the tool is aimed to designers of SharePoint solutions, I like to use it for deploying solutions to different or additional web applications without having to retract it first.

The official description, grabbed from the iDevFactory.com website states the following:

SharePoint Work Acceleration Toolkit (SWAT) is a windows based utility aimed at simplifying and accelerating the creation and testing of SharePoint Solutions. With a whole host of time saving capabilities and planned integration with Universal SharePoint Manager 2007, you’ll never want to take on SharePoint without it again.

SWAT Features and Capabilities:
Here is a short list of just some of the things SWAT can do. For a complete overview checkout the SWAT User Guide.

  • Site Diagramming
    • Show a Site Structure as a Diagram
    • Save a Site Structure Diagram as a Image
    • Save a Site Structure Diagram as a SVG file (for importing into Visio)
    • Print a Site Diagram
    • Drag and Drop the design of a Site Structure
  • Generate Test Data and Sites
    • Generate Random Sites for Testing
    • Auto Populate Lists/Libraries with Test Data (including Documents)
  • Work with SharePoint Logs
    • View SharePoint Log Files in a preview window
    • Group and Filter Log file entries
  • Work with Sites
    • Show a Site Structure in a Tree View (including security inheritence)
    • Create a Site Collection
    • Export and Import Site Structures
    • Backup and Restore Site Collections
    • View and Interact with site objects (Lists, Users, Roles, Features, Events, etc..)
    • Delete Sites and entire Site Structures
  • Work with SharePoint Features
    • View Feature Status in Farm and on a Site
    • Install and Uninstall Features
    • Activate and Deactivate Features
  • Work with SharePoint Solution Packages
    • Install and Deploy Solution Packages
    • View Solution Deployment Locations (Servers and Web Apps)
    • Deploy, Retract and Delete Solutions
  • Work with SharePoint Jobs
    • View Job Status
    • Add and Schedule Jobs
    • Enable and Disable Jobs
    • Force Execution of Jobs
  • Work with Event Receviers
    • Install Event Receivers for Sites and Lists
    • View and Manage Event Receivers
    • Delete Event Receivers
  • Work with Web Parts
    • Add (Deploy) Web Parts to multiple sites/pages
    • Replicate Web Parts
    • Delete Web Parts from multiple sites/pages

…and much much more!   These are just some of the features available in the SharePoint Work Acceleration Toolkit.

And now for the good part of this tool: ….. IT’S FREE

Read all about it here

SPS2003 Lock site using command line: SPSiteManager

yeah yeah, if you are used to working with MOSS, then you will probably tell me to use the command stsadm -o setsitelock -url <url> -lock readonly or something like that.

Unfortunately back in the SharePoint Portal Server 2003 and WSS 2.0 days, this operation was no yet available with stsadm…..along with a lot of other usefull commands

I needed to lock the sps 2003 sites in a gradual upgrade project to MOSS. Of course I want to script the complete migration, which also includes locking the SPS site before starting the upgrade.

Searching the web, I found my way to the SPSiteManager project on Codeplex 

In addition to the opeartions I was looking for, you also get the following operations:

Operation

Description

analyze

Enumerate all Content Database information and generate a Site Distribution Document

repartition

Re-partition sites to different content databases

enumsites

Enumerate Site Collections

Enumsitecrawl

Enumerate URL references from the list of sites to crawl

Enumsitedirectory

Enumerate URL references from a portals site directory

enumdatabases

Enumerate Content Databases

backup

Backup site(s)

restore

Restore site(s)

deletesite

Delete site(s)

adddatabase

Add content databases to a virtual server

addfromcrawl

Add site(s) to list of sites to crawl for SharePoint Portal Server 2003

removefromcrawl

Remove site(s) to list of sites to crawl for SharePoint Portal Server 2003

addfromdirectory

Add site(s) to Portal Server 2003 Site Directories

removefromdirectory

Remove site(s) to Portal Server 2003 Site Directories

locksite

Lock site(s)

unlocksite

Unlock site(s)

resetquota

Reset quotas on site(s)

purgeversions

Purge document versions from document libraries

Although these operations look a lot like the ones we get with MOSS, nowadays, they actually are much better. For example the operation to backup a site will actually also lock the site for read/write for you and unlock it when done. So before using this tool with all the operations, be sure to check out the well written manual that is included explaining each operation.

 

Tim Dobrinski’s SharePoint Space Monitor

While searching through the Technet SharePoint forum, I stumbled upon a post/question regarding how to find out how much data your subsites are using. I remember from the SPS 2003 days that there was a aspx page that would show this ( _layouts/storman.aspx), which actually still exists in MOSS, but is accessible ony if you have a storage quota defined on the site collection (maybe it was also the case already in SPS, but I am not sure). It is accessible though the Site Settings page listed as a link called storage space allocation

Well, Tom Dobrinski developped a tool that allows you to get this information regardless of the fact if storage quotas are enabled or not. Even more he has made it available free of charge, but you are kindly suggested to make a small donation (5$) to get a everlasting key for the tool. Otherwise you will have to drop Tim a mail requesting a key every 4 months or so…

Go check his blog for the tool called the SharePoint Space Monitor if you think it might be usefull to you.

Extract the installed solutions from the MOSS farm (updated)

I was looking today for a way to get all the original wsp and cab files that have been installed into a MOSS farm. Of course not everybody keeps track of where the original files are the same way. Certainly if there is a team that is managing the same MOSS farms, your original files get lost very rapidly, or you can find the files on the filesystem, but there are so many versions of them. which one is the latest and the version installed?

So I was thinking that there should be a way to extract them from MOSS directly. Of course there is no OOTB way to do this, but I found some code that allows you to do it. The piece of code was posted on a Technet blog comment

I basically took this code and wrote a small Console Application around it so I could use it on my systems.

*** UPDATE March 23rd 2009***

Once I had created my little tool to extract the solutions, I noticed that it would also be great to know what the properties are of the solutions. Where were they deployed to, etc. Therefore I added some code to generate in addition to the solution files also a corresponding xml file containing that information

I will share my updated code:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SharePoint.Administration;

using System.Xml;

 

namespace SolutionExtractor

{

    class Program

    {

        static void Main(string[] args)

        {

            if (args.GetLength(0) == 0)

            {

                Console.WriteLine(“Usage: SolutionExtracter.exe <path to save solution files>”);

                return;

            }

            string path = args[0].ToString();

           

            bool checkIfDirExists = System.IO.Directory.Exists(path);

            if (checkIfDirExists == false)

            {

                Console.WriteLine(“path “+path+ ” does not exist”);

                return;

            }

 

            SPSolutionCollection solutions = SPFarm.Local.Solutions;

 

            foreach (SPSolution solution in solutions)

            {

                SPPersistedFile wspFile = solution.SolutionFile;

                Console.WriteLine(“Saving “+path +“\\” + solution.Name);

                wspFile.SaveAs(path +“\\” + solution.Name);

               

                Console.WriteLine(“Saving properties to “ + path + “\\” + solution.Name + “.xml”);

                string filename = path + “\\” + solution.Name + “.xml”;

                XmlTextWriter tw =new XmlTextWriter(filename,null);//null represents the Encoding Type//

                tw.Formatting=Formatting.Indented;  //for xml tags to be indented//

                tw.WriteStartDocument();   //Indicates the starting of document (Required)//

                tw.WriteStartElement(“Solution”);

                tw.WriteAttributeString(“Name”, solution.Name);

                tw.WriteStartElement(“Properties”);

                tw.WriteElementString(“Added”, solution.Added.ToString());

                tw.WriteElementString(“ContainsCasPolicy”, solution.ContainsCasPolicy.ToString());

                tw.WriteElementString(“ContainsGlobalAssembly”, solution.ContainsGlobalAssembly.ToString());

                tw.WriteElementString(“ContainsWebApplicationResource”, solution.ContainsWebApplicationResource.ToString());

                tw.WriteElementString(“Deployed”, solution.Deployed.ToString());

                

                tw.WriteStartElement(“DeployedServers”);

                foreach(SPServer s in solution.DeployedServers)

                    tw.WriteElementString(“Server”, s.Name);

                tw.WriteEndElement();

               

                tw.WriteElementString(“DeploymentState”, solution.DeploymentState.ToString());

                if (solution.DeploymentState.ToString().ToLower() != “globaldeployed”)

                {

                    tw.WriteStartElement(“DeployedWebApplications”);

                    foreach (SPWebApplication w in solution.DeployedWebApplications)

                        tw.WriteElementString(“WebApplication”, w.Name);

                    tw.WriteEndElement();

                }

                tw.WriteElementString(“IsWebPartPackage”, solution.IsWebPartPackage.ToString());

                tw.WriteElementString(“SolutionId”, solution.SolutionId.ToString());

              

                tw.WriteEndElement();

                tw.WriteEndDocument();                                 

                tw.Flush();

                tw.Close();

            }

 

        }

    }

}

 

 

 

So after running this code you will find all the solutions accompanied by an xml file with the properties like this:

 <?xml version=1.0?>
<
Solution Name=mySolution.wsp>
  <
Properties>
    <
Added>True</Added>
    <
ContainsCasPolicy>False</ContainsCasPolicy>
    <
ContainsGlobalAssembly>True</ContainsGlobalAssembly>
    <
ContainsWebApplicationResource>True</ContainsWebApplicationResource>
    <
Deployed>True</Deployed>
    <
DeployedServers>
        <
Server>MOSS01</Server>
        <Server>MOSS02</Server>
    </
DeployedServers>
    <
DeploymentState>GlobalAndWebApplicationDeployed</DeploymentState>
    <DeployedWebApplications>
       <
WebApplication>SharePoint – WebApp1</WebApplication>
       <
WebApplication>SharePoint – WebApp2</WebApplication>
    </
DeployedWebApplications>
    <
IsWebPartPackage>False</IsWebPartPackage>
    <
SolutionId>eb07011e-3898-4d51-8e23-008a890c6549</SolutionId>
  </
Properties>
</
Solution>

For Those of you that do not want to start developping or compiling this peace of code, you can download an updated compressed version of it attached to this post.

Adobe PDF iFilter 64 bit finally released spotted by Brendan Griffin

Hi,


I just came across a post by Brendan Griffin on the From the Field Blog ( great blog by the way!) about this long awaited release of a 64bit iFilter for pdf from Adobe. It is finally there. Read more about it on http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025 


The installation procedure for SharePoint is available which requires you to play around in the registry to make it actually work.


This release will probably be bad and sad news for Foxit Software that was until now one of the only suppliers of a 64bit PDF iFilter on the market.