Created
August 3, 2022 17:09
-
-
Save lacherogwu/cfb8af48bcf56dd96da216391477a407 to your computer and use it in GitHub Desktop.
Reset Windows Mac Address & VolumeId
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } | |
function Get-RandomAlphanumericString | |
{ | |
Param($length) | |
return -join ((65..70) + (48..57) | Get-Random -Count $length | % {[char]$_}) | |
} | |
# Change Mac Address | |
$array = @() | |
for($i=1; $i -le 6; $i++){ | |
$array += Get-RandomAlphanumericString 2 | |
} | |
$macAddress = $array -join "-" | |
Set-NetAdapterAdvancedProperty -Name "Ethernet" -DisplayName "Mac Address" -DisplayValue "$macAddress" | |
# Change Volume ID | |
$VolumeIdFileName = 'Volumeid' | |
$VolumeIdDir = 'c:\VolumeId' | |
$VolumeIdFileExists = Test-Path -Path "$VolumeIdDir\$VolumeIdFileName.exe" | |
function Create-VolumeIdFolder | |
{ | |
$LocalTempDir = $env:TEMP | |
$DownloadUrl = 'https://download.sysinternals.com/files/VolumeId.zip' | |
Invoke-WebRequest -Uri $DownloadUrl -OutFile "$LocalTempDir\$VolumeIdFileName.zip" | |
Expand-Archive "$LocalTempDir\$VolumeIdFileName.zip" -DestinationPath $VolumeIdDir | |
Remove-Item "$LocalTempDir\$VolumeIdFileName.zip" | |
} | |
if( !$VolumeIdFileExists ) | |
{ | |
Create-VolumeIdFolder | |
} | |
$array = @() | |
for($i=1; $i -le 2; $i++){ | |
$array += Get-RandomAlphanumericString 4 | |
} | |
$volumeId = $array -join "-" | |
& "$VolumeIdDir\$VolumeIdFileName.exe" C: $volumeId | |
#Restart-Computer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PowerShell -ExecutionPolicy Unrestricted C:\reset-data.ps1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment