There was some test code at the end of Invoke-ShellcodeMSIL that would cause the function to execute when the script was dotsourced.
Invoke-ShellcodeMSIL executes shellcode without making any Win32 function calls.