$admin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”) if($admin -eq $True){ $user = Read-Host -Prompt "Please enter the username you wish to appear as the last logged on account" $domain = Read-Host -Prompt "Please enter the domain you wish to appear as the last logged on account" reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI /v LastLoggedOnSAMUser /d "$domain\$user" /f reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI /v LastLoggedOnUser /d "$domain\$user" /f shutdown /l /f }else{ Write-Host "Please re-run this script as an administrator." } write-host "Finished."