As part of the summary script I use the following code to get the SharePoint 2010 version. This identifies which CU or Service Pack has been installed.
There are a couple of ways for getting the build version:
1. Using Central Administration
It is of course possible to get the build version using central administration by going to ‘Central Administration –> System Settings –> Manage servers in this farm’
2. Using get-spfarm
You can use the following line of code to get the buildversion
|get-spfarm | select BuildVersion|
3. Using [Microsoft.SharePoint.Administration.SPFarm]::Local
This command outputs the same values as get-spfarm.
Use .tostring() to get the version as string.