How to change GUID in windows

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:

  1. Open Task Scheduler (taskschd.msc).
  2. In the right-hand action pane, click Create Task… (do not use Create Basic Task, as it lacks advanced privilege options).
  3. General Tab:
    • Name: Reset MachineGuid on Boot
    • Select Run whether user is logged on or not.
    • Check Run with highest privileges.
  4. Triggers Tab:
    • Click New…, and set Begin the task to At startup. Click OK.
  5. 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.
  6. 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.
  7. Click OK and enter your administrator credentials when prompted.

Leave a Comment