Using GUI elements in a PowerShell remoting session isn't supported, because the server component that services the caller's request runs in an invisible window station and the remoting protocol is solely based on communicating the output from PowerShell commands (including output from non-interactive console programs) back to the caller:
In the case of calling the [Microsoft.VisualBasic.Interaction]::InputBox() method, the method itself detects that it is running in an invisible window station and emits the following error message:
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.[1]
In other cases, such as trying to launch notepad.exe, the failure may be silent (process creation may succeed, but nothing ever becomes visible, and the process may shut itself down shortly after creation).
You can try one of the following workarounds:
Present the GUI element on the client side before invoking the remoting command, and pass the result as an argument to the remote command.
Use the console-based Read-Host cmdlet instead.
- Note: External programs that prompt the user for input are not supported in remoting sessions, even if they prompt in the console; e.g.,
cmd /c 'set /p foo="Enter something: "' instantly returns instead of prompting.
[1] The workaround suggested by this error message does not work in remote sessions; if it were effective, the dialog would uselessly display on the server; what actually happens if you call with such a style (directly via [System.Windows.Forms.MesssageBox]::Show(), given that [Microsoft.VisualBasic.Interaction]::InputBox() doesn't support specifying these styles) is that no dialog is shown and the default-button response is instantly returned.