Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.38 KB | None | 0 0
  1.  
  2. $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
  3.  
  4. function Get-RandomString {
  5. param([int]$Length,
  6. [int]$upperCase,
  7. [int]$onlyNumber)
  8.  
  9. if ($onlynumber -eq 1) {
  10. $set = "0123456789".ToCharArray()
  11. }
  12. else {
  13. $set = "abcdef0123456789".ToCharArray()
  14. }
  15.  
  16. $result = ""
  17. for ($x = 0; $x -lt $Length; $x++) {
  18. $result += $set | Get-Random
  19. }
  20.  
  21. if ($upperCase -eq 1) { return $result.ToUpper() }
  22. else { return $result }
  23.  
  24. }
  25.  
  26. function Set-HWProfileID {
  27.  
  28. $registryPath = "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0001"
  29. $registryKeyName = "HwProfileGuid"
  30.  
  31. $HwProfile = Get-ItemProperty -Path $registryPath -Name $registryKeyName
  32.  
  33. $len = $HwProfile.HwProfileGuid.Length
  34. $Rand1 = Get-RandomString -Length 8 -upperCase 0 -onlyNumber 0
  35. $Rand2 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
  36. $Rand3 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
  37. $Rand4 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
  38. $Rand5 = Get-RandomString -Length 12 -upperCase 0 -onlyNumber 0
  39. $RandID = "{$Rand1-$Rand2-$Rand3-$Rand4-$Rand5}"
  40.  
  41. Set-ItemProperty -Path $registryPath -Name $registryKeyName -Value $RandID
  42.  
  43. }
  44.  
  45. function Set-ProductID {
  46.  
  47. $registryPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
  48.  
  49. $registryKeyName = "ProductId"
  50.  
  51. $HwProfile = Get-ItemProperty -Path $registryPath -Name $registryKeyName
  52.  
  53. $len = $HwProfile.HwProfileGuid.Length
  54. $Rand1 = Get-RandomString -Length 5 -upperCase 0 -onlyNumber 1
  55. $Rand2 = Get-RandomString -Length 5 -upperCase 0 -onlyNumber 1
  56. $Rand3 = Get-RandomString -Length 5 -upperCase 0 -onlyNumber 1
  57. $Rand4 = Get-RandomString -Length 5 -upperCase 1 -onlyNumber 0
  58. $RandID = "$Rand1-$Rand2-$Rand3-$Rand4"
  59.  
  60. $RandName = Get-RandomString -Length 10 -upperCase 1 -onlyNumber 0
  61. $InstallDate = [int][double]::Parse($(Get-Date -date (Get-Date).ToUniversalTime()-uformat %s))
  62. $InstallTimeRand = Get-RandomString -Length 16 -upperCase 0 -onlyNumber 1
  63. $InstallTime = "13$installTImeRand"
  64.  
  65.  
  66. Set-ItemProperty -Path $registryPath -Name $registryKeyName -Value $RandID
  67. Set-ItemProperty -Path $registryPath -Name "RegisteredOwner" -Value $RandName
  68. Set-ItemProperty -Path $registryPath -Name "InstallDate" -Value $InstallDate
  69. Set-ItemProperty -Path $registryPath -Name "InstallTime" -Value $InstallTime
  70.  
  71. }
  72.  
  73. function Set-VolID {
  74.  
  75.  
  76. $volidPath = "$scriptPath\Volumeid64.exe"
  77. $volID1 = Get-RandomString -Length 4 -upperCase 1 -onlyNumber 0
  78. $volID2 = Get-RandomString -Length 4 -upperCase 1 -onlyNumber 0
  79. $volidArgs = "C: $volID1-$volID2"
  80.  
  81. $ps = New-Object System.Diagnostics.Process
  82. $ps.StartInfo.FileName = $volidPath
  83. $ps.StartInfo.Arguments = $volidArgs
  84. $ps.StartInfo.RedirectStandardOutput = $False
  85. $ps.StartInfo.UseShellExecute = $True
  86. $ps.StartInfo.WindowStyle = "Hidden"
  87. $ps.StartInfo.CreateNoWindow = $True
  88. $psReturnCOde = $ps.Start()
  89.  
  90. if (-Not $ps.WaitForExit(10000)) { $ps.kill() }
  91.  
  92. }
  93.  
  94. function Set-DiskGPTID {
  95.  
  96.  
  97. $diskGPTPath = "diskpart"
  98. $diskGPTID1 = Get-RandomString -Length 8 -upperCase 0 -onlyNumber 0
  99. $diskGPTID2 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
  100. $diskGPTID3 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
  101. $diskGPTID4 = Get-RandomString -Length 4 -upperCase 0 -onlyNumber 0
  102. $diskGPTID5 = Get-RandomString -Length 12 -upperCase 0 -onlyNumber 0
  103. $diskGPTID = "$diskGPTID1-$diskGPTID2-$diskGPTID3-$diskGPTID4-$diskGPTID5"
  104.  
  105. $diskpartScriptFile = New-Item "$scriptPath\diskpart.txt" -type file -force
  106. Add-Content "$scriptPath\diskpart.txt" "select disk 1"
  107. Add-Content "$scriptPath\diskpart.txt" "uniqueid disk id=$diskGPTID"
  108.  
  109. sleep -Seconds 2
  110.  
  111.  
  112. $diskGPTArgs = "/s ""$scriptPath\diskpart.txt"""
  113.  
  114. $ps = New-Object System.Diagnostics.Process
  115. $ps.StartInfo.FileName = $diskGPTPath
  116. $ps.StartInfo.Arguments = $diskGPTArgs
  117. $ps.StartInfo.RedirectStandardOutput = $False
  118. $ps.StartInfo.UseShellExecute = $True
  119. $ps.StartInfo.WindowStyle = "Hidden"
  120. $ps.StartInfo.CreateNoWindow = $True
  121. $psReturnCOde = $ps.Start()
  122.  
  123. if (-Not $ps.WaitForExit(10000)) { $ps.kill() }
  124.  
  125. }
  126.  
  127. function Set-ComputerName {
  128.  
  129. $computerNameRand1 = Get-RandomString -Length 6 -upperCase 1
  130. $computerNameRand = "DESKTOP-$computerNameRand1"
  131.  
  132. Rename-Computer -ComputerName "localhost" -NewName $computerNameRand
  133.  
  134. }
  135.  
  136.  
  137. $answer = Read-Host -Prompt "******** WARNING! Read careful! ******** `n `nRequirements `n 1. You are running W7 or later as 64-bit Version `n 2. Your Harddrive is formated as GPT and not MBR (check google what that means and how to check) `n `n Press [y] if you agree to continue or any other key to abort."
  138.  
  139.  
  140.  
  141. if ($answer -eq "y") {
  142.  
  143.  
  144. try
  145. {
  146. Write-Host "Changing HWProfile GUID..."
  147. Set-HWProfileID
  148. Write-Host "Done"
  149. }
  150. catch
  151. {
  152. Write-Host "ERROR: Could not change HWProfile GUID (run Script as Administrator)"
  153. }
  154.  
  155.  
  156. try
  157. {
  158. Write-Host "Changing Windows Product ID..."
  159. Set-ProductID
  160. Write-Host "Done"
  161. }
  162. catch
  163. {
  164. Write-Host "ERROR: Could not change WIndows Product ID (run Script as Administrator)"
  165. }
  166.  
  167.  
  168. try
  169. {
  170. Write-Host "Changing VolumeID GUID..."
  171. Set-VolID
  172. Write-Host "Done"
  173. }
  174. catch
  175. {
  176. Write-Host "ERROR: Could not change Volume GUID (run Script as Administrator)"
  177. }
  178.  
  179.  
  180. try
  181. {
  182. Write-Host "Changing GPT GUID..."
  183. ###### Does not work yet
  184. #Set-DiskGPTID
  185. Write-Host "Done"
  186. }
  187. catch
  188. {
  189. Write-Host "ERROR: Could not change GPT GUID (run Script as Administrator)"
  190. }
  191.  
  192. try
  193. {
  194. Write-Host "Changing PC Name..."
  195. Set-ComputerName
  196. Write-Host "Done"
  197. }
  198. catch
  199. {
  200. Write-Host "ERROR: Could not change PC Name (run Script as Administrator)"
  201. }
  202.  
  203.  
  204. $answer = Read-Host -Prompt "WARNING! The PC needs a restart for changes to take effect. `n `nALSO CHANGE YOUR MAC ADDRESS AND YOUR IP!`n `nPress [y] to accept or any other key to manual restart later."
  205.  
  206. if ($answer -eq "y") {
  207. Restart-Computer -Force
  208. }
  209.  
  210. }
  211. else {
  212.  
  213. Write-Host "Aborted"
  214.  
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement