What gets displayed if you stick in a tracer:

$x=WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon","1", "REG_SZ")

? "ERROR " + @ERROR + " : " + @SERROR