0
votes

error code:

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation.

i want to display the messagebox (which is part of the script) on the host-computer while i'm running a remote command

here is my code:

Invoke-Command -ComputerName NAME -Credential USER -FilePath FILEPATH

i want to execute a script which is stored locally and display the messagebox

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$versioncheck = (get-host).Version.Major

If ($versioncheck -ge 3)

{[System.Windows.Forms.MessageBox]::Show("Aktuelle Version von PowerShell: $versioncheck", "Status") }

else

{[System.Windows.Forms.MessageBox]::Show("Aktuelle Version von PowerShell: $versioncheck. Dies entspricht nicht den Anforderungen!", "Status")}

He doesn´t show the message box! Please help me - sorry for my english.

1

1 Answers

0
votes

As the error message indicates, your remote script can't interact with the interactive user on the remote machine. One workaround is to create a scheduled task that runs a script that shows the message box. Set the scheduled task to "Run only when the user is logged on" so that the message box will be able to popup on the user's desktop (assuming they're logged in). Another option is to use psexec with its -i option.