-
Notifications
You must be signed in to change notification settings - Fork 0
/
hwid.ps1
105 lines (79 loc) · 3.19 KB
/
hwid.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
function Get-RandomString {
param([int]$Length,
[int]$upperCase,
[int]$onlyNumber)
if ($onlynumber -eq 1) {
$set = "0123456789".ToCharArray()
}
else {
$set = "abcdef0123456789".ToCharArray()
}
$result = ""
for ($x = 0; $x -lt $Length; $x++) {
$result += $set | Get-Random
}
if ($upperCase -eq 1) { return $result.ToUpper() }
else { return $result }
}
function Set-HWProfileID {
$registryPath = "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0001"
$registryKeyName = "HwProfileGuid"
$HwProfile = Get-ItemProperty -Path $registryPath -Name $registryKeyName
$len = $HwProfile.HwProfileGuid.Length
$Rand1 = Get-RandomString -Length 8 -upperCase 0 -onlyNumber 0
$Rand2 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
$Rand3 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
$Rand4 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
$Rand5 = Get-RandomString -Length 12 -upperCase 0 -onlyNumber 0
$RandID = "{$Rand1-$Rand2-$Rand3-$Rand4-$Rand5}"
Set-ItemProperty -Path $registryPath -Name $registryKeyName -Value $RandID
}
function Set-MachineGUID {
$registryPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography"
$registryKeyName = "MachineGuid"
$HwProfile = Get-ItemProperty -Path $registryPath -Name $registryKeyName
$len = $HwProfile.HwProfileGuid.Length
$Rand1 = Get-RandomString -Length 8 -upperCase 0 -onlyNumber 0
$Rand2 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
$Rand3 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
$Rand4 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
$Rand5 = Get-RandomString -Length 12 -upperCase 0 -onlyNumber 0
$RandID3 = "$Rand1-$Rand2-$Rand3-$Rand4-$Rand5"
Set-ItemProperty -Path $registryPath -Name $registryKeyName -Value $RandID3
}
function Set-VolID {
$volidPath = "$scriptPath\Volumeid64.exe"
$volID1 = Get-RandomString -Length 4 -upperCase 1 -onlyNumber 0
$volID2 = Get-RandomString -Length 4 -upperCase 1 -onlyNumber 0
$volidArgs = "C: $volID1-$volID2"
$volidArgs1 = "$volID1-$volID2"
$ps = New-Object System.Diagnostics.Process
$ps.StartInfo.FileName = $volidPath
$ps.StartInfo.Arguments = $volidArgs
$ps.StartInfo.RedirectStandardOutput = $False
$ps.StartInfo.UseShellExecute = $True
$ps.StartInfo.WindowStyle = "Hidden"
$ps.StartInfo.CreateNoWindow = $True
$psReturnCOde = $ps.Start()
if (-Not $ps.WaitForExit(10000)) { $ps.kill() }
}
try
{
Write-Host "The operation completed successfully."
Set-HWProfileID
}
catch
{
Write-Host "ERROR: Could not change HWProfile GUID (run Script as Administrator)"
}
try
{
Write-Host "The operation completed successfully."
Set-MachineGUID
Write-Host "The operation completed successfully."
}
catch
{
Write-Host "ERROR: Could not change Volume GUID (run Script as Administrator)"
}