Recently, I created a script that utilizes GUI's such as Out-GridView and Winforms and puts that module on a remote Windows 2012 server. This was to allow users to establish remote PSSessions and execute scripts from a centralized location.
For Example:
1. When attempting to call a winform I get the following error:
Exception calling "ShowDialog" with "0" argument(s): "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."
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
+ PSComputerName : servera
2. When attempting to place results into an Out-GridView I get the following error:
Out-GridView does not work in a remote session.
+ CategoryInfo : InvalidOperation: (Microsoft.Power...GridViewCommand:OutGridViewCommand) [Out-GridView], NotSupportedException
+ FullyQualifiedErrorId : RemotingNotSupported,Microsoft.PowerShell.Commands.OutGridViewCommand
+ PSComputerName : servera
Question:
Are there any workarounds that would allow me to utilize OGV and Winforms?
Side note: I am open to allowing the user to export the module to their physical workstation to let them use these options if need be - OGV and Winforms - only if there is an effective/secure means to do it.On the other hand, I am open to different suggestions.
You need to use the UI on your local machine, not the remote one. Retrieve data remotely, display locally.
For instance:
Invoke-Command -ComputerName RemoteServer -Scriptblock { Get-Process } | Out-Gridview
Using the gridview inside the scriptblock will attempt to launch the UI on RemoteServer and give you the error you mentioned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With