Locating files with a specific size in SharePoint

Locating large files in a large SharePoint environment can be a tiresome job. This week, I was asked to find out how many images were uploaded which are larger than 500Kb.

Doing this with PowerShell is fairly easy.

This script can be adapted easily to find other types of files by changing the following line:

Finding CEWP’s with script in your SharePoint sites

One of the most annoying things I regularly encounter is undocumented environments. Nothing freaks me out more than this.

For instance, last week, I stumbled onto a search results page which didn’t work anymore. Seems that once upon a time, someone added a content editor webpart with some javascript on there. That javascript called a webservice and this failed.

If I didn’t have the reflex of putting that page in edit mode, I would never have guessed this. This lead me to the creation of the following… a PowerShell script which identifies all pages, forms and views for a webapplication which has:

  • a CEWP with the <script> tag
  • a CEWP with a contentlink that points to a textfile wich has the <script> tag

This way, I don’t have to go fish for these things if people are too damn lazy to create some documentation.

Create a cache profile in SharePoint using PowerShell

I have been looking for a way to create a new cache profile in SharePoint using Powershell. This profile can be used in the Page Output cache.
I noticed that cache profiles are stored in a list called “Cache Profiles” and implement the “Page Output Cache” content type.

So, creating a new profile shouldn’t be that difficult.

 

To add the profile to your Page Output Cache and enable the cache, you can use the following code:

Create Content Organizer Rules using PowerShell

I just wanted to share a way to create Content Organizer rules in SharePoint 2010 using PowerShell. I was looking for a way to implement those rules using a script.

The first thing I did was create a rule using the UI and then fire up SharePoint Manager to have a look at it and how it has been built up.

So, those rules are stored in a hidden list called “Content Organizer Rules”. Creating a new listitem in that list however is not that straightforward. I did found out that a rule is actually an instance of the Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule class. The link above contains an example on how to create a rule programmatically.

If it’s possible in C#, then it must be possible in PowerShell.
The script below is what I came up with and it works like a charm:

The thing to remember is the ConditionsString property. If you don’t specify a specific condition, you can’t just leave it empty. You have to include the tags of the Conditions element. If you do need to specify additional conditions, then the easiest way to construct this string is to create the rule in the UI, inspect the Xml string of the rule with SharePoint Manager and look at the “ows_RoutingConditions” argument, which contains the condition.