Revert "win_setup: Add Product ID and Product Key in facts" (#35200)

* Revert "win_setup: Add Product ID and Product Key in facts (#34097)"

This reverts commit cf1f7b53df.
This commit is contained in:
Dag Wieers 2018-01-22 22:32:23 +01:00 committed by GitHub
parent dd5256f3df
commit 7f6feca82f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,35 +54,6 @@ Function Get-MachineSid {
return $machine_sid
}
Function Get-ProductKey {
# First try to find the product key from ACPI
$product_key = (Get-CimInstance -Class SoftwareLicensingService).OA3xOriginalProductKey
if (-not $product_key) {
# Else try to get it from the registry instead
$data = Get-ItemPropertyValue -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion" -Name DigitalProductId
$hexdata = $data[52..66]
$chardata = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"
# Decode base24 binary data
$product_key = $null
for ($i = 24; $i -ge 0; $i--) {
$k = 0
for ($j = 14; $j -ge 0; $j--) {
$k = $k * 256 -bxor $hexdata[$j]
$hexdata[$j] = [math]::truncate($k / 24)
$k = $k % 24
}
$product_key = $chardata[$k] + $product_key
if (($i % 5 -eq 0) -and ($i -ne 0)) {
$product_key = "-" + $product_key
}
}
}
return $product_key
}
$result = @{
ansible_facts = @{ }
changed = $false
@ -209,8 +180,6 @@ $ansible_facts = @{
ansible_nodename = ($ip_props.HostName + "." + $ip_props.DomainName)
ansible_os_family = "Windows"
ansible_os_name = ($win32_os.Name.Split('|')[0]).Trim()
ansible_os_product_id = $win32_os.SerialNumber
ansible_os_product_key = Get-ProductKey
ansible_owner_contact = ([string] $win32_cs.PrimaryOwnerContact)
ansible_owner_name = ([string] $win32_cs.PrimaryOwnerName)
ansible_powershell_version = ($PSVersionTable.PSVersion.Major)