Benutzer mit den meisten Antworten
Product Key auslesen

Frage
-
Guten Tag,
im Rahmen einer Fehlerbehebung muss ich einige Product Key's auslesen. Da sich dazu schon jemand Gedanken gemacht hat und eine Funktion geschrieben hat, der auch einen kompetenten Eindruck macht ^^, habe ich dieses Script mal übernommen (Leider kann ich den Link hier nicht Posten, die Funktion steht aber in der Script Repository und die Funktion heißt Get-ProductKey) Ich bekomme auch ein Product key von diesem Script zurückgeliefert, es ist jedoch nicht der erwartete denn wenn ich an dem gleichen Computer den letzten Block des Product key's über slmgr abfrage, stimmt der nicht mit dem von Powershell ausgegebenen überein.
Kann es sein das auf einem Rechner verschiedene Product key's existieren?
Antworten
-
Also wenn du hier von Skripten redest musst du schon genauer sein. Auch slmgr ist nur ein VBS script!
Wir reden hier zur Zeit also über 3 Scripte.
1. slmngr
2. Get-ProductKey von Boe Prox
3. Get-WindowsProductKey von dem MS Team und von mir Modifiziert.
Wir haben bei uns hier Windows 7 Enterprise mit KMS Lizenzen.
Das Heisst auf allen unseren Rechner ist die lizenz gleich.Die KMS Lizenzen werden nur benötigt damit man Windows überhaupt Installieren kann. Die eigentliche unsichbare Lizens bekommen die Rechner vom KMS Server!
Sieh hier : https://www.rrzn.uni-hannover.de/kms.html
und hier: KMS Client Setup Keys
http://technet.microsoft.com/en-us/library/jj612867.aspxWenn ich nun das Script von Boe Prox im vergleich mit slmgr laufen lasse, bekomme ich unterschiedliche Nummer auf Windows 7 Enterprise.
Wenn ich meine hier geposteten Code laufen lasse im Vergleich mit slmgr laufen lasse bekomme ich gleiche Nummern auf Windows 7 Enterprise.
Ich werde das nochmal zuhause testen, da habe ich aber nur noch Win 8 und 8.1.....
slmngr benutzt intern die WMI Klasse "SoftwareLicensingProduct" um die Partitielle Nummer auszulesen.
Damit du nicht immer du kannst ja in meine Funktion die Folgen Zeile als vergleich nutzen:Get-WmiObject SoftwareLicensingProduct | Where {$_.Description -like "*Windows Operating System*" -and $_.PartialProductKey} | Select-Object -ExpandProperty PartialProductKey
PowerShell Artikel, Buchtipps und kostenlose PowerShell Tutorials + E-Books
auf der deutschsprachigen PowerShell Community
Mein 21 Teiliger PowerShell Video Grundlehrgang
Deutsche PowerShell Videos auf Youtube
Folge mir auf:
Twitter | Facebook | Google+- Bearbeitet Peter Kriegel Donnerstag, 13. März 2014 07:24
- Als Antwort vorgeschlagen Alex Pitulice Montag, 24. März 2014 17:52
- Als Antwort markiert Alex Pitulice Dienstag, 1. April 2014 12:38
Alle Antworten
-
Kann es sein das auf einem Rechner verschiedene Product key's existieren?
Ja!
z.B. mit dem UEFI BIOS und Windows 8 wird die Seriennummer von den OEMs im BIOS abgelegt.
habe ich dieses Script mal übernommen (Leider kann ich den Link hier nicht Posten, die Funktion steht aber in der Script Repository und die Funktion heißt Get-ProductKey)
Es gibt keinen Grund diesen Links hier nicht zu Posten!
Im Gegenteil, es wäre sehr Hilfreich, damit wir hier auch über ein und dieselbe Sache reden!
In der Diskusion über die Funktion wird diese Frage ebenfalls gestellt und nicht beantwortet:
Probiere es mal damit:
PowerShell Artikel, Buchtipps und kostenlose PowerShell Tutorials + E-Books
auf der deutschsprachigen PowerShell Community
Mein 21 Teiliger PowerShell Video Grundlehrgang
Deutsche PowerShell Videos auf Youtube
Folge mir auf:
Twitter | Facebook | Google+- Bearbeitet Peter Kriegel Mittwoch, 12. März 2014 09:31
-
Doch einen Grund gibt es, ich bin frisch registriert und bei der Erstellung des Beitrags konnte ich aus diesem Grund keinen Link einstellen.
Da war ich wohl ein bisschen zu ungenau. Es handelt sich um Windows 7. Die Frage in der Diskussion habe ich auch schon gesehen. Da das alles aber schon länger her ist hatte ich die Befürchtung auf eine erneute Frage auch keine Antwort zu bekommen.
- Bearbeitet myon86 Mittwoch, 12. März 2014 09:55
-
Ok!
Dann Probiere es mal damit (Funktioniert bei mir mit Windows 7):
Function Get-WindowsProductKey { <# .Synopsis Function to get the Windows Product-Key (license number) from the Local or remote System .DESCRIPTION Retrieves the product key and OS information from a local or remote system/s. Queries of 64bit OS from a 32bit OS may result in inaccurate data being returned for the Product Key. You must query a 64bit OS from a process running at 64bit. .PARAMETER Computername Specifies the target computer for the management operation. Enter a fully qualified domain name, a NetBIOS name, or an IP address. When the remote computer is in a different domain than the local computer, the fully qualified domain name is required. The default is the local computer. To specify the local computer, such as in a list of computer names, use "localhost", the local computer name, or a dot (.). This parameter does not rely on Windows PowerShell remoting, which uses WS-Management. You can use the ComputerName parameter of Get-WmiObject even if your computer is not configured to run WS-Management remote commands. .PARAMETER Credential Specifies a user account that has permission to perform this action. The default is the current user. Type a user name, such as "User01", "Domain01\User01", or User@Contoso.com. Or, enter a PSCredential object, such as an object that is returned by the Get-Credential cmdlet. When you type a user name, you are prompted for a password. Note: If you Provide Credentials you cannot query the local system! .NOTES Original Author : Microsoft All-In-One Script Framework Link: http://gallery.technet.microsoft.com/Backup-Windows-product-key-b41468c2 The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages Edited by: Peter Kriegel to use it even with Windows 7 (and other Windows Versions) .EXAMPLE Get-WindowsProductKey Querys the local computer .EXAMPLE Get-WindowsProductKey -Computername "Server1","Server3","Server3" Querys the remote computer systems with the names Server1,Server3 and Server3 #> [CmdletBinding()] param( [Parameter(ValueFromPipeLine=$True,ValueFromPipeLineByPropertyName=$True)] [Alias("CN","__Server","IPAddress","Server")] [string[]]$ComputerName = @($Env:ComputerName), [System.Management.Automation.PSCredential]$Credential ) Begin{ # declare function to convert binary to serial number Function ConvertToKey($Key) { $Keyoffset = 52 $isWin8 = [int]($Key[66]/6) -band 1 $HF7 = 0xF7 $Key[66] = ($Key[66] -band $HF7) -bOr (($isWin8 -band 2) * 4) $i = 24 [String]$Chars = "BCDFGHJKMPQRTVWXY2346789" do { $Cur = 0 $X = 14 Do { $Cur = $Cur * 256 $Cur = $Key[$X + $Keyoffset] + $Cur $Key[$X + $Keyoffset] = [math]::Floor([double]($Cur/24)) $Cur = $Cur % 24 $X = $X - 1 } while($X -ge 0) $i = $i- 1 $KeyOutput = $Chars.SubString($Cur,1) + $KeyOutput $last = $Cur } while($i -ge 0) $Keypart1 = $KeyOutput.SubString(1,$last) $Keypart2 = $KeyOutput.Substring(1,$KeyOutput.length-1) if($last -eq 0 ) { $KeyOutput = "N" + $Keypart2 } else { $KeyOutput = $Keypart2.Insert($Keypart2.IndexOf($Keypart1)+$Keypart1.length,"N") } $a = $KeyOutput.Substring(0,5) $b = $KeyOutput.substring(5,5) $c = $KeyOutput.substring(10,5) $d = $KeyOutput.substring(15,5) $e = $KeyOutput.substring(20,5) $keyproduct = $a + "-" + $b + "-"+ $c + "-"+ $d + "-"+ $e $keyproduct } } # end Begin{} block Process{ ForEach($Computer in $Computername) { # create empty Result Object $Result = New-Object -TypeName PSObject | Select-Object ProductName,ProductID,ProductKey,ProductVersion,Computername # test if ComputerName is a IPv4 or IPv6 Address $IP = [System.Net.IPAddress]'192.168.0.1' # dummy target IPAddress Object for the output of [ref]$IP in next line If ([System.Net.IPAddress]::TryParse($Computer,[ref]$IP)) { # Convert to String IP to an knowen String (e.g: '127.000.000.001' will be '127.0.0.1' after that!) $Computer = $IP.ToString() } # convert all localhost addresse to real computername IF($Computer -eq 'localhost' -or $Computer -eq '127.0.0.1' -or $Computer -eq '.' -or $Computer -eq '::1') { $Computer = $Env:ComputerName } $Result.Computername = $Computer # create WMI Registry Object $Hklm = 2147483650 $wmi = $Null If($Credential) { $wmi = Get-WmiObject -list "StdRegProv" -namespace root\default -computername $Computer -credential $credential } Else { $wmi = Get-WmiObject -list "StdRegProv" -namespace root\default -computername $Computer } # get 'DigitalProductId' value from registry [Array]$DigitalIDvalue = ($wmi.GetBinaryValue($hklm,'Software\Microsoft\Windows NT\CurrentVersion','DigitalProductId')).uValue # if DigitalIDvalue is not null If($DigitalIDvalue) { # Get product name and product ID from registry $Result.ProductName = $wmi.GetStringValue($hklm,'Software\Microsoft\Windows NT\CurrentVersion','ProductName').sValue $Result.ProductId = $wmi.GetStringValue($hklm,'Software\Microsoft\Windows NT\CurrentVersion','ProductId').sValue $Result.ProductVersion = $wmi.GetStringValue($hklm,'Software\Microsoft\Windows NT\CurrentVersion','CurrentVersion').sValue + "." + $wmi.GetStringValue($hklm,'Software\Microsoft\Windows NT\CurrentVersion','CurrentBuildNumber').sValue # Convert binary value to serial number $Result.ProductKey = ConvertTokey $DigitalIDvalue # if ProductKey is null if(-not $Result.ProductKey) { Write-Warning "Failed to calculate Windows product key from 'HKey_Local_Machine\Software\Microsoft\Windows NT\CurrentVersion\DigitalProductId'." } # return result $Result } Else { Write-Warning "Failed to get Windows product key from Registry 'HKey_Local_Machine\Software\Microsoft\Windows NT\CurrentVersion\DigitalProductId'." } $Result = $Null } # end ForEach($Computer) } # end Process{} block End{ } # end End{} block } # end Function
PowerShell Artikel, Buchtipps und kostenlose PowerShell Tutorials + E-Books
auf der deutschsprachigen PowerShell Community
Mein 21 Teiliger PowerShell Video Grundlehrgang
Deutsche PowerShell Videos auf Youtube
Folge mir auf:
Twitter | Facebook | Google+- Bearbeitet Peter Kriegel Donnerstag, 13. März 2014 07:19
-
Ich bekomme bei beiden Scripten einen Key, der jedoch nicht der ist der installiert ist (slmgr Zeigt einen anderen Key an) die beiden Scripte lesen ja den gleichen Reg Schlüssel aus, was sie unterscheidet ist nur die "Übersetzung" des digitalen Werts in einen Product Key so wie wir ihn kennen. Das lustige das die beiden Scripts, trotz gleichem Input doch einen unterschiedlichen Output liefern -.-
-
Am 12.03.2014 schrieb myon86:
Doch einen Grund gibt es, ich bin frisch registriert und bei der Erstellung des Beitrags konnte ich aus diesem Grund keinen Link einstellen.
Du kannst deinen Account in diesem Thread verifzieren lassen:
http://social.microsoft.com/Forums/en-US/reportabug/thread/1f541d13-8b01-4e95-831a-379ecabecb46#1f541d13-8b01-4e95-831a-379ecabecb46Da war ich wohl ein bisschen zu ungenau. Es handelt sich um Windows 7. Die Frage in der Diskussion habe ich auch schon gesehen. Da das alles aber schon länger her ist hatte ich die Befürchtung auf eine erneute Frage auch keine Antwort zu bekommen.
Es geht weniger um W7, bei neueren Rechnern ist der Key im BIOS, bei
älteren eben nicht.
Servus
Winfried
Gruppenrichtlinien
WSUS Package Publisher
HowTos zum WSUS Package Publisher
NNTP-Bridge für MS-Foren -
Also wenn du hier von Skripten redest musst du schon genauer sein. Auch slmgr ist nur ein VBS script!
Wir reden hier zur Zeit also über 3 Scripte.
1. slmngr
2. Get-ProductKey von Boe Prox
3. Get-WindowsProductKey von dem MS Team und von mir Modifiziert.
Wir haben bei uns hier Windows 7 Enterprise mit KMS Lizenzen.
Das Heisst auf allen unseren Rechner ist die lizenz gleich.Die KMS Lizenzen werden nur benötigt damit man Windows überhaupt Installieren kann. Die eigentliche unsichbare Lizens bekommen die Rechner vom KMS Server!
Sieh hier : https://www.rrzn.uni-hannover.de/kms.html
und hier: KMS Client Setup Keys
http://technet.microsoft.com/en-us/library/jj612867.aspxWenn ich nun das Script von Boe Prox im vergleich mit slmgr laufen lasse, bekomme ich unterschiedliche Nummer auf Windows 7 Enterprise.
Wenn ich meine hier geposteten Code laufen lasse im Vergleich mit slmgr laufen lasse bekomme ich gleiche Nummern auf Windows 7 Enterprise.
Ich werde das nochmal zuhause testen, da habe ich aber nur noch Win 8 und 8.1.....
slmngr benutzt intern die WMI Klasse "SoftwareLicensingProduct" um die Partitielle Nummer auszulesen.
Damit du nicht immer du kannst ja in meine Funktion die Folgen Zeile als vergleich nutzen:Get-WmiObject SoftwareLicensingProduct | Where {$_.Description -like "*Windows Operating System*" -and $_.PartialProductKey} | Select-Object -ExpandProperty PartialProductKey
PowerShell Artikel, Buchtipps und kostenlose PowerShell Tutorials + E-Books
auf der deutschsprachigen PowerShell Community
Mein 21 Teiliger PowerShell Video Grundlehrgang
Deutsche PowerShell Videos auf Youtube
Folge mir auf:
Twitter | Facebook | Google+- Bearbeitet Peter Kriegel Donnerstag, 13. März 2014 07:24
- Als Antwort vorgeschlagen Alex Pitulice Montag, 24. März 2014 17:52
- Als Antwort markiert Alex Pitulice Dienstag, 1. April 2014 12:38