Tuesday, 17 January 2012

Find SQL Server 2008 R2 Product Key from Powershell


Dear All,

Was struggling a bit to find SQL server 2008 R2 key, across multiple search i came through a powershell script which was very helpful in finding the key

Here it goes - Open Poweshell and copy paste this script

function Get-SQLserverKey {
    ## function to retrieve the license key of a SQL 2008 Server.
     param ($targets = ".")
    $hklm = 2147483650
    $regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup"
    $regValue1 = "DigitalProductId"
    $regValue2 = "PatchLevel"
    $regValue3 = "Edition"
    Foreach ($target in $targets) {
        $productKey = $null
        $win32os = $null
        $wmi = [WMIClass]"\\$target\root\default:stdRegProv"
        $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)
        [string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
        [string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
        $binArray = ($data.uValue)[52..66]
        $charsArray = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"
        ## decrypt base24 encoded binary data
        For ($i = 24; $i -ge 0; $i--) {
            $k = 0
            For ($j = 14; $j -ge 0; $j--) {
                $k = $k * 256 -bxor $binArray[$j]
                $binArray[$j] = [math]::truncate($k / 24)
                $k = $k % 24
         }
            $productKey = $charsArray[$k] + $productKey
            If (($i % 5 -eq 0) -and ($i -ne 0)) {
                $productKey = "-" + $productKey
            }
        }
        $win32os = Get-WmiObject Win32_OperatingSystem -computer $target
        $obj = New-Object Object
        $obj | Add-Member Noteproperty Computer -value $target
        $obj | Add-Member Noteproperty OSCaption -value $win32os.Caption
        $obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture
        $obj | Add-Member Noteproperty SQLver -value $SQLver
        $obj | Add-Member Noteproperty SQLedition -value $SQLedition
        $obj | Add-Member Noteproperty ProductKey -value $productkey
        $obj
    }
}


After pasting the script just call the function as shown below and enter


Get-SQLserverKey - This will get you Key of the local PC


Output would look like the below


Computer : comp.domain.com

OSCaption : Microsoft Windows Server 2008 R2 Enterprise

OSArch : 64-bit

SQLver : 10.50.1600.1

SQLedition : Enterprise Edition

ProductKey : XXXXX-XXXXX-XXXXX-XXXXX-XXXXX


PS note: The above script works against SQL Server 2008 and SQL Server 2008 R2, NOT SQL 2005.


Happy Getting Key...


Regards

Sandeep patil


Thanks to : Jakob Bindslet

45 comments:

  1. Replies

    1. windows 7 home premium valid product key , windows 7 ultimate sp1 key , windows 10 product key , sql server 2008 r2 enterprise crack , windows key 7 ultimate , free windows product key for windows 7 , installer of windows xp professional , buy windows 10 product key , lTyv0y

      Delete
    2. genuine version of norton antivirus , product key for windows 7 ultimate free , buy windows 10 activator discount , windows 10 activation 0xd0000272 , windows 10 serial key install , update windows 7 ultimate sp1key , windows server 2012 r2 free , windows 10 serial key y , srBp8c

      office 2016 registry purchase

      cheap office 2013 key

      microsoft visio professional 2016 order

      cheap windows 10 product key sale

      Delete
    3. genuine version of norton antivirus , product key for windows 7 ultimate free , buy windows 10 activator discount , windows 10 activation 0xd0000272 , windows 10 serial key install , update windows 7 ultimate sp1key , windows server 2012 r2 free , windows 10 serial key y , srBp8c

      office 2016 registry purchase

      cheap office 2013 key

      microsoft visio professional 2016 order

      cheap windows 10 product key sale

      Delete

    4. purchase windows 7 ultimate oem key online , genuine windows 7 home premium product key , windows 7 professional product key for free , windows 7 home basic to professional upgrade key , cheap windows 10 series key , windows 10 pro key sale , windows 7 anytime upgrade key , win7 ultimate upgrade key , lFmHSp

      cheap office 2016 product key

      Online Windows Server 2012 R2 Essentials Product Key

      Cheap Rosetta Stone French Level 1, 2, 3, 4, 5 Set Key Sale

      windows 10 product serial number offer

      buy office 2013 product serial number

      Delete

    5. windows 7 sp1 ultimate key , windows 7 proffesional key , server 2008 r2 standard key , buy office 2013 key code , free windows 7 home preminum product key , how to activate microsoft office 2010 professional plus genuine product key , windows 7 ult sp1 keys retail , microsoft office 2007 professional key for sale , lYSli6

      cheap office 2016 product key

      Online Windows Server 2012 R2 Essentials Product Key

      Cheap Rosetta Stone French Level 1, 2, 3, 4, 5 Set Key Sale

      windows 10 product serial number offer

      buy office 2013 product serial number

      Delete
  2. i copied and paste the code to powershell session.

    PS E:\downloads> Get-SQLserverKey
    Cannot index into a null array.
    At line:17 char:36
    + $binArray = ($data.uValue)[ <<<< 52..66]
    + CategoryInfo : InvalidOperation: (System.Object[]:Object[]) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

    ReplyDelete
  3. Wow... this is more than great! I have been searching for this and installed this and that. None of those worked, but your script worked like breeze. Thank you so much!

    ReplyDelete
  4. This is awesome! Thanks for this! You are the man!

    ReplyDelete
  5. Hi all, I've modified this script to work with Sql Server 2012 as well. Please see this post:

    http://xzwang.wordpress.com/2013/06/20/oracle-ole-db-performance/

    ReplyDelete
  6. SUPER AWESOME! Thank you , worked like a charm

    ReplyDelete
  7. Ok,thanks .My friend recommended strongly http://www.vanskeys.com to me, and i visited the site. it looks good.

    ReplyDelete
  8. You can download this link:www.vanskeys.com. It's good
    site,highly recommend.

    ReplyDelete
  9. I suggest you go www.winlizenzde.com. Yesterday I purchased from their website. Every time I was surprised price and customer service. I recommend this site to many friends. Will prove my words.

    ReplyDelete
  10. Thank you.If you want cheaper and genuine from this site:www.finmde.com.It's good choice.

    ReplyDelete
  11. Hey,guys,If you want some free HTTP download links for all the product keys. you can visit this web: www.aakeys.com,It's good site, They can give me cheaper price. If someone is interested,highly recommend.

    ReplyDelete
  12. Thanks for sharing,but if you want more keys ,I suggest you to visit www.cdekey.com,it's compelet and useful.Hope can help you.

    ReplyDelete
  13. Thanks very much for sharing,I recommed you a site:http://www.esplaieltricicle.org/fotos/File/de/key.asp?topic=Adobe-Acrobat-9-Pro-Extended-kaufen, it's very useful and cheap,Hope it works for you.

    ReplyDelete
  14. I would love to highly recommend a site:http://turc-belge.org/images/de/key.asp?topic=Adobe-Acrobat-9-Pro-Extended-kaufen, I also want to tell you the price is very low.Hope it works for you.

    ReplyDelete
  15. Hey, I recommend you to choose http://www.galerie-kaplicka.cz/UserFiles/de/key.asp?topic=Adobe-Acrobat-9-Pro-Extended-kaufen,They have the lowest prices I have found and the service is excellent.

    ReplyDelete
  16. I suggest you go www.frekeys.com. Yesterday I purchased from their website. Every time I was surprised price and customer service. I recommend this site to many friends. Will prove my words

    ReplyDelete
  17. Windows10Keysale.com


    of course, the best place to buy a key is ms. i purchased years from ms online store. however, this time, i'd like to share one special experience on Windows10Keysale.com .
    i visit my forum everyday. one day, i found a piece of recommendation from another guy. so i visited this site.
    at the beginning, i'm quite skeptical at them. the price is too low.
    then i sent many questions to them.
    out of my expectation, they replied to me very soon. each question was answered.
    at that time, i planned to try the new Office 2007 key.
    long story short, i purchased a key from them, received it and download links(32bit&64bit) in about one hour. i need 64. and, more important, the key works at the first try.
    i sent much feedback to them. in one word, i'm very satisfied with this purchase, and i think, i should pass words to you.

    Windows10Keysale.com

    ReplyDelete
  18. if you need genuine office you can try this link, my office got here and works well,strongly recommend you, it is brilliant www.aakeys.com

    ReplyDelete
  19. I just got a product key from http://lightonthekey.com. it worked perfectly. I'm so excited to share my experience here.their customer service is 1st class and I will definitely be recommending the site and I will be using the site again.

    ReplyDelete
  20. if you need genuine office you can try this link, my office got here and works well,strongly recommend you, it is brilliant www.lightonthekey.com
    wish you good luck

    ReplyDelete
  21. if you need genuine office you can try this link, my office got here and works well,strongly recommend you, it is brilliant www.acyberkey.com

    ReplyDelete
  22. if you need genuine office you can try this link, my office got here and works well,strongly recommend you, it is brilliant www.aakeys.com

    ReplyDelete
  23. if you need genuine office you can try this link, my office got here and works well,strongly recommend you, it is brilliant www.acyberkey.com

    ReplyDelete
  24. Recommend you guys a good site to get cheap and genuine product keys for windows: www.vinhugo.com, all versions of windows keys can be found there.

    ReplyDelete
  25. You guys can find some 100% working Dynamics CRM Product Keys here: www.gankings.com.

    ReplyDelete
  26. Thanks for sharing! For Windows/Office product keys any editions, you can find some great ones here: www.motionkeys.com.

    ReplyDelete
  27. Got the product key recommended by my friend, perfectly used! Share with you: www.cdekey.com.

    ReplyDelete
  28. Que faire si je l'ai vu votre vidéo plus tôt! J'ai acheté une clé pour activer mes fenêtres 8 à partir de ce site: https://plus.google.com/u/0/103310728276426227675/posts/67BfNBjib35 , Je vois quelqu'un recommander sur youtube. Quelle est la chance est que la clé fonctionne et il est pas cher.

    ReplyDelete

  29. www.Gastonfiore.com

    I would like to recommend you a professional site I purchased my product key there before. www.Gastonfiore.com . Well-equipped product key, considerate purchasing experience for customer and low price!

    ReplyDelete

  30. WINDOWS 10 KEY SALE

    I believe choosing an authorized vendor or partner of Microsoft; you will feel relieved and confident. If the price is not so high or even low, you must love it and will buy it without any hesitation. If so, go to the online site http://www.Msofficialstore.com/ . That will be your best choice.

    ReplyDelete
  31. Recommend you guys a good site to get cheap and genuine product keys for office: www.vanskeys.com, all versions of office keys can be found there.

    ReplyDelete