Powershell – Check for Enterprise Edition, Change if not present.

Not that easy to change the licensekey of your SharePoint farm programmatically. So got help from a few of colleagues and created the below to do just that.

#--Checking for Enterprise edition key and changing if not Enterprise Edition
$ServerVersion= Get-ItemProperty "HKLM:SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\InstalledProducts"
$CurrentKey= $Serverversion."{90140000-110D-0000-1000-0000000FF1CE}"

If ($CurrentKey -eq "D5595F62-449B-4061-B0B2-0CBAD410BB51")
write-host "Enterprise edition"
Else {write-host "Installing enterprise edition"
#The product key to enter
$Pkey = "<SharePoint 2010 Enterprise Edition license key"

#Get the central admin URL
$CAUrl = (Get-spwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication}).Url
$UpgradePage = $CAUrl + "_admin/SkuUpgrade.aspx"

$ie = New-Object -ComObject "InternetExplorer.Application"

#wait for central Admin to load

while ($ie.ReadyState -ne 4)
sleep -Milliseconds 100
$RadioButton = $ie.Document.getElementById("ctl00_PlaceHolderMain_ctl00_AdminSkuUpgradeSelectFeaturesRadioGroup_RadioBtnPremiumFeatures")
$ProductKeyBox = $ie.Document.getElementById("ctl00_PlaceHolderMain_FormSectionPidKey_AdminSkuUpgradePidKeyTextBox_TextBoxPidKey")
$ProductKeyBox.value = $Pkey
$Button = $ie.Document.getElementById("ctl00_PlaceHolderMain_BtnSectionBottom_RptControls_BtnSaveBottom")

Stop-Process -Name iexplore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.