SharePoint 2007 File Inventory

Once again, I am reminded of how much I can appreciate the PowerShell snap-ins for SharePoint after the 2010 release. Attempting to iterate through a farm or script out actions using only STSADM commands and direct access to the SharePoint assemblies ([System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)) is much more challenging than using the built-in PowerShell capabilities of the later versions (even SharePoint Online with it’s own quirks).

I have a client who is migrating from an on-premise SharePoint 2007 environment to SharePoint Online. Yes – big jump, and yes – there will be some headaches. So many features and functions of SharePoint 2007 simply will not migrate and/or be mappable to equivalent SharePoint Online features due to the sheer difference in the way each of the platforms are laid out. Due to this, identifying some of these issues proactively before a migration rather than reacting to broken page layouts, missing site feature dependencies, and other prerequisites is greatly beneficial. To make matters a step more complicated, the client had elected to engage in a branding effort to give their SharePoint Online instance a fresh new look that resulted in a site that really didn’t look like SharePoint at all in the end.

So how do you migrate a bunch of SharePoint 2007 ASPX pages, based on deprecated site templates and layouts, into a branded SharePoint Online instance which utilizes a specific page layout for branding and the site home pages?

You don’t.

Lucky this client didn’t have very customized site home pages or a large extent of customized pages throughout their farm, so efforts to re-create these pages into branded SPO pages manually was feasible. In order to prepare for this work and delegate out this ASPX page recreation to site owners, the client wanted to have an inventory of all ASPX pages in their farm currently, with location. Per my normal consulting habits, I was confident in telling the client we could figure out a way to give them this report to help them plan this work out, yet I was not 100% sure how I would do it at that time. Now was time to search for how to get a SharePoint 2007 file inventory, and then strip out everything besides the ASPX pages from the list.

Through some research online, it was easy to find all arrows pointing to Gary LaPointe. The SharePoint MVP is THE man when it comes to STSADM commands. His website has WSP solutions for installing snap-ins with SharePoint 2010+ PowerShell commands, as well as some scripts here. Lucky for me, he had one script on his website which iterated through every web application in the local farm, and drilled down through each Site Collection, subsite, and document library recursively and output the results to either a grid view or a CSV file. View the script below, as well as a link to Gary’s personal blog which I would highly recommend to any SharePoint consultant or legacy farm administrator

View the script on his site HERE, as well as the downloads page which features a large library of tools and scripts for completing unique tasks that aren’t quite perfectly mapped out in OoB cmdlets.

Powershell in MOSS 2007 – Site Maps

So you have a client that’s running MOSS 2007. With the features and benefits of SharePoint 2013, it’s easy to get quickly frustrated with this old version of SharePoint. Nothing irks me more than forgetting about the lack of PowerShell, each and every time, and spending time looking up STSADM equivalent cmdlets to achieve the same task.

Isn’t there some way I can PowerShell SharePoint 2007?

Yes, but it kind of sucks. I would always recommend using STSADM commands natively when possible, but there really isn’t a good alternative to PowerShell sometimes. Windows SharePoint Services 3.0 and SharePoint Server 2007 do no include built-in cmdlets, but we can do the following if PowerShell is at least installed on the server:

1. Run the following to set the execution policy to allow for scripts to be run locally (this may or may not be reversed/denied via group policy:

2. Load the SharePoint API into you script with the following:

3. Load the MOSS 2007 Script Collection from CodePlex onto the machine HERE

4. Create a new PS1 file with the following format:

The above will run the two referenced PS1 files and keep them in memory preemptively to calling the cmdlets in the script later, and when they are, the console knows where to look for them.

The following can be done via native STSADM to create the same type of output (Note: the enumallwebs command is an STSADM command that is only available in SP ’07 SP2 and above):

Both of these options clearly will work, but the output will be different and some may prefer to stick to STSADM when possible in the older environments.

In the end, this is simply a workaround that allows you to run a small sub-set of your PowerShell scripts that you know and love from SP’13 and SP’10 over a MOSS2007 farm when STSADM commands just fall short.