Use PowerShell to Remove an Orphaned Custom Site Template from SharePoint 2010


A situation cropped up today where a custom Site Template was created by saving a site as a template which was then used and subsequently deactivated and then deleted. Simple enough except that SharePoint insisted that the template was still there and presented it as a choice when creating new sites even though it didn’t exist and would fail if someone clicked on it.

I could have simply gone into Site Settings – Page Layouts and Site Templates and hidden it there but that raises other problems as well as adds ongoing maintenance as it means all new templates would have to be explicitly added in order to be visible. However, even if I did that Click to read the full post

Upload Files to SharePoint using PowerShell


SharePoint admins occasionally have write PowerShell scripts to regularly extract some type of summary data from the SharePoint farm and then write that out to a file, usually in CSV format since PowerShell handles those so well. This is great for admins because we can just log onto the box and open the file to read the data, but what about the rest of the SharePoint team that also needs that data? Click to read the full post

PowerShell Syntax Highlighting script


As a SharePoint administrator, I end up either writing a lot of PowerShell scripts or copying existing scripts and modifying them to fit a new need.  With all of these scripts comes the need to share them with other admins outside of the command line and in such a way that allows them to be easily Click to read the full post

Automatically Set the AssemblyFileVersion for Visual Studio Projects


One of the more annoying quirks with dealing with SharePoint is that once you develop a solution that requires custom code, all dependencies are then tied to the Strong Name of the compiled DLL.  That strong name also includes the version number, usually 1.0.0.0, and cannot be changed without breaking all existing references.  This is a good thing from a compatibility perspective but it does make it rather complicated to figure out exactly which version of a DLL is in use.

You can open up the WSP and then use the timestamps and take a guess at the version but it is not always reliable.  Click to read the full post

Creating GUIDs in PowerShell


When you work with SharePoint, you end up working a lot with both GUIDs and with PowerShell. Strangely enough, the two together don’t seem to be needed very much but eventually their paths cross. GUIDs in PowerShell are amazingly simple to create but the web is chock full of misinformation and insanely complicated suggestions. I’ve even seen some folks recommend passing parameters to New-Object!

So, just for the sake of clarity, here is how to create GUIDs in PowerShell.  It really doesn’t get much simpler than this!

# Create an empty GUID

   $Id = [GUID]::Empty


# Create a new GUID

   $Id = [GUID]::NewGuid()


# Create a GUID with a value

   $Id = [GUID]("b2e92f11-7f65-41d1-acec-ba051b418bdf")

There’s nothing to it but some people choose to make this so complicated.

Update – 5/31/13 – I discovered a way to make it even simpler!