In Windows the call of powershell should be including the argument -NoProfile to avoid loading stuff a user wants in their interactive session. Perhaps also a good idea is to also include the argument -NonInteractive so the session would fail rather than waiting forever for a possible user input. Of course that's highly unlikely for a simple call of gwmi but it sure would not hurt.
Thanks for the good work!