Skip to content

Instantly share code, notes, and snippets.

Last active February 20, 2023 09:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
SetupComplete - Enable Builtin Administrator
$ErrorActionPreference = "Stop"
Set-StrictMode -version Latest
$path = "$($Env:SystemRoot)\OEM"
New-Item -ItemType Directory -Path $path -Force
# Use single-quote for the here-string so the text isn't interpolated
$adminAccount = Get-WmiObject Win32_UserAccount -filter "LocalAccount=True" | ?{$_.SID -Like "S-1-5-21-*-500"}
Write-Host "Admin account was disabled. Enabling the Admin account."
$adminAccount.Disabled = $false
Write-Host "Admin account is enabled."
# Since we are using SetupComplete2.cmd, add a hook for future us to use SetupComplete3.cmd
if (Test-Path $Env:SystemRoot\OEM\SetupComplete3.cmd)
& $Env:SystemRoot\OEM\SetupComplete3.cmd
'@ | Out-File -Encoding ASCII -FilePath "$path\SetupComplete2.ps1"
"powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File %~dp0SetupComplete2.ps1" | Out-File -Encoding ASCII -FilePath "$path\SetupComplete2.cmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment