Step 1: Create the PowerShell Automation Script
Save the following code as a .ps1 file (for example, C:\Scripts\Reset-MachineGuid.ps1):
PowerShell
# Ensure the script runs with administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "Administrator privileges required. Relaunching script..."
Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
# Define the registry path
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Cryptography"
$ValueName = "MachineGuid"
# Generate a new random GUID
$NewGuid = [guid]::NewGuid().ToString()
try {
# Set the new MachineGuid
Set-ItemProperty -Path $RegistryPath -Name $ValueName -Value $NewGuid -ErrorAction Stop
Write-Output "Successfully updated MachineGuid to: $NewGuid"
}
catch {
Write-Error "Failed to update MachineGuid: $_"
}
Step 2: Configure a Scheduled Task for Startup
To ensure the script executes automatically before user logon every time the machine boots:
- Open Task Scheduler (
taskschd.msc). - In the right-hand action pane, click Create Task… (do not use Create Basic Task, as it lacks advanced privilege options).
- General Tab:
- Name:
Reset MachineGuid on Boot - Select Run whether user is logged on or not.
- Check Run with highest privileges.
- Name:
- Triggers Tab:
- Click New…, and set Begin the task to At startup. Click OK.
- Actions Tab:
- Click New…, and set Action to Start a program.
- Program/script:
powershell.exe - Add arguments:
-ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Scripts\Reset-MachineGuid.ps1"(adjust path to match your saved script). Click OK.
- Conditions & Settings Tabs:
- Ensure Start the task only if the computer is on AC power is unchecked if this is running on a desktop or a test server that might flip power states.
- Click OK and enter your administrator credentials when prompted.