Function Get-SharePointInstall
{
if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue)
{
# New way, borrowed from xSharePoint DSC project (https://github.com/PowerShell/xSharePoint)
if (Get-CimInstance -ClassName Win32_Product -Filter "Name like 'Microsoft SharePoint Server%'")
...
Probably needs to have an additional check for Foundation, if the detection needs to avoid false positives from SP Designer etc.
Comments: ** Comment from web user: Emblematic **
Sure! Here are the values from 2013 and 2010.
Cheers
Bob
PS C:\> Get-CimInstance -ClassName Win32_Product -Filter "Name like 'Microsoft SharePoint%'" | format-list
IdentifyingNumber : {90150000-1110-0000-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2013
Vendor : Microsoft Corporation
Version : 15.0.4569.1506
Caption : Microsoft SharePoint Foundation 2013
IdentifyingNumber : {90150000-1014-0000-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2013 Core
Vendor : Microsoft Corporation
Version : 15.0.4569.1506
Caption : Microsoft SharePoint Foundation 2013 Core
IdentifyingNumber : {90150000-1015-0409-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2013 1033 Lang Pack
Vendor : Microsoft Corporation
Version : 15.0.4569.1506
Caption : Microsoft SharePoint Foundation 2013 1033 Lang Pack
IdentifyingNumber : {90150000-1158-0409-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2013 1033 SQL Express
Vendor : Microsoft Corporation
Version : 15.0.4569.1506
Caption : Microsoft SharePoint Foundation 2013 1033 SQL Express
PS C:\> Get-CimInstance -ClassName Win32_Product -Filter "Name like 'Microsoft SharePoint%'" | format-list
IdentifyingNumber : {90140000-1110-0000-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2010
Vendor : Microsoft Corporation
Version : 14.0.7015.1000
Caption : Microsoft SharePoint Foundation 2010
IdentifyingNumber : {90140000-1014-0000-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2010 Core
Vendor : Microsoft Corporation
Version : 14.0.7015.1000
Caption : Microsoft SharePoint Foundation 2010 Core
IdentifyingNumber : {90140000-1015-0409-1000-0000000FF1CE}
Name : Microsoft SharePoint Foundation 2010 1033 Lang Pack
Vendor : Microsoft Corporation
Version : 14.0.7015.1000
Caption : Microsoft SharePoint Foundation 2010 1033 Lang Pack