Compiled your project and launched the test.exe on Windows 7. Environment
variables removed to the minimum -- Path, PSModulePath, TEMP, TMP, etc.
removed. Executed from an Admin account and a Standard User account.
GetLastError always returned 0 :-(
Friedrich