Detect OOBE - Script to see if an AutoPilot device is in OOBE
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path -ErrorAction Ignore
cd $ScriptDir -ErrorAction Ignore
$LoggedOnUser = Get-WmiObject win32_computersystem | select Username -ErrorAction Ignore
$user = $LoggedOnUser.Username
$count = 0
while($user -like "")
{
$LoggedOnUser = Get-WmiObject win32_computersystem | select Username -ErrorAction Ignore
$user = $LoggedOnUser.Username
$count++
sleep -Seconds 5
}
If($LoggedOnUser.Username -like "*defaultuser0")
{
Write-Output "OOBE"
exit 0
}
else
{
exit 12345
}
No comments:
Post a Comment