Skip to main content

Blogging about SharePoint

Go Search
Home
Blogging about SharePoint
Public Speaking
  

Michael Blumenthal's BlumenthalIT.NET > Blogging about SharePoint > Posts > PowerShell script to report SharePoint version number – Improved!
PowerShell script to report SharePoint version number – Improved!

I was recently recording a webcast for Connections Online about using PowerShell with SharePoint, and I put together what I think it a pretty cool four lines of code:

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local

$bv = $farm.BuildVersion.ToString()

$vertable = Import-Csv versions.csv

$vertable | where-object {$_.Version -eq $bv}

A sample versions.csv file is here: http://blumenthalit.net/Files/PowerShell%20Scripts/versions.csv

What the last line of the script returns is a description of the version (e.g. “April CU”) plus the corresponding WSS and MOSS KB articles IDs.

Part of the beauty of this is that I didn’t have to do anything complex to store my data – it took me just a few minutes to create my csv file by hand, and I didn’t have to deal with parsing it, or with picking a collection datatype (List, HashTable, etc) to store it in.  Import-CSV, which is a cmdlet that ships with PowerShell v1.0 did all that for me.

You can download the script file here:  Get-sharepointversion.ps1 (put it in the same folder as the CSV file).

One of these days, I should move that into CodePlex.com/PSBB, but not today.

Michael

Comments

Great work

Great work Michael, I've added this to the <a href="http://sharepointadminwiki.com/display/SharePointAdministrationWiki/SharePoint+Versions">SharePoint Versions</a> page of the SharePointAdminWiki.com!

at 7/18/2009 10:39 PM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Please put your name at the end of your comment as the Name field doesn't display in the main view of the comments.

Name: *


Your name.  If you first name is Michael, please provide initials or the like to clearly distinguish your name from Michael Blumenthal's.
Also, this field does not appear in the main view of the comments.

Need Paid Consulting Services?

Are you interested in engaging a SharePoint consultant for fee-based consulting services?  If so, I can have an Account Executive from my employer contact you.  Other site visitors will not see this column.

Additional Contact Information

Please provide additional contact information if you need a direct response.  Other site visitors will not see this column.

What is tomorrow's date? *

This is a weak CAPTCHA based on advice from a tweet from @ToddKlindt.
Attachments