Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Calculate-ProductKey {
- param ($rpk)
- if ($rpk)#if rpk present - do math
- {
- $i = 28
- $rpkOffset = 52
- $PossibleChars = "BCDFGHJKMPQRTVWXY2346789"
- do {
- $Accumulator = 0
- $j = 14
- do {
- $Accumulator = $Accumulator * 256
- $Accumulator = $rpk[$j + $rpkOffset] + $Accumulator
- $Accumulator / 24 -match "^\d*" | Out-Null
- $rpk[$j + $rpkOffset] = $matches[0] -band 255
- $Accumulator = $Accumulator % 24
- $j--
- } while ($j -ge 0)
- $i--
- $ProductKey = $PossibleChars.Substring($Accumulator, 1) + $ProductKey
- if ((29 - $i) % 6 -eq 0 -and $i -ne -1) {
- $i--
- $ProductKey = "-" + $ProductKey
- }
- } while ($i -ge 0)
- $ProductKey
- }
- else
- { "Not Available" }
- }
- function Get-RegistryValues {
- param ($strcomputer)
- #create object for output
- $object = new-object psobject
- #create wmi object
- $wmi2 = "\\"+$strComputer+"\root\default:stdRegProv"
- $wmi = [wmiclass]$wmi2
- #get IE version
- $hklm = 2147483650
- $key = "SOFTWARE\Microsoft\Internet Explorer\"
- $value = "Version"
- $IEVersion = ($wmi.GetStringValue($hklm,$key,$value)).sValue
- $object | add-member noteproperty IEVer ($IEVersion)
- #get windows product key
- $key = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
- $value = "DigitalProductId"
- $WinPK = ($wmi.GetBinaryValue($hklm,$key,$value)).uValue
- $WinPK = Calculate-ProductKey $WinPK
- $object | add-member noteproperty WindowsProductKey ($WinPK)
- #get shell
- $key = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
- $value = "Shell"
- $WindowsShell = ($wmi.GetStringValue($hklm,$key,$value)).sValue
- $object | add-member noteproperty WindowsShell ($WindowsShell)
- #get userinit
- $key = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
- $value = "Userinit"
- $UserInit = ($wmi.GetStringValue($hklm,$key,$value)).sValue
- $object | add-member noteproperty UserInit ($UserInit)
- #get automatic updates status
- $key = "SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\"
- $value = "NoAutoUpdate"
- $NoAutoUpdate = ($wmi.GetDWORDValue($hklm,$key,$value)).uValue
- $object | add-member noteproperty NoAutoUpdate ($NoAutoUpdate)
- $value = "AUOptions"
- $AUOptions = ($wmi.GetDWORDValue($hklm,$key,$value)).uValue
- $object | add-member noteproperty AUOptions ($AUOptions)
- #return object
- $object
- }
- # Usage:
- #
- # Get-RegistryValues [computername]
- # For ex.: Get-RegistryValues . (get values from local machine)
- # For ex.: Get-RegistryValues SUPERSERVER (get values from SUPERSERVER machine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement