locked
REST Service processing PowerShell commands RRS feed

  • Question

  • I created a WCF REST service running under IIS to process PowerShell commands.  Most of the time the PowerShell script runs successfully without throwing any errors.  On occasion though I am seeing 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. 

    I suspect this issue occurs when there are concurrent calls to the REST service resulting in simultaneous PowerShell sessions.  Following are the commands I execute to establish the PowerShell session.  I am not sure if I am missing anything since this needs to execute non-interactive concurrent sessions.

    Set-ExecutionPolicy RemoteSigned
    $pw = convertto-securestring -AsPlainText -Force -String "Password"
    $cred = new-object -typename PSCredential -argumentlist "Login", $pw
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication Basic -AllowRedirection
    Import-PSSession $Session 
    Connect-MsolService -Credential $cred

    Tuesday, February 26, 2019 3:10 PM

Answers

  • Connect Msol first then connect Outlook.  This is an old bug.


    \_(ツ)_/

    • Marked as answer by DotNetDon Tuesday, February 26, 2019 3:36 PM
    Tuesday, February 26, 2019 3:26 PM

All replies

  • Connect Msol first then connect Outlook.  This is an old bug.


    \_(ツ)_/

    • Marked as answer by DotNetDon Tuesday, February 26, 2019 3:36 PM
    Tuesday, February 26, 2019 3:26 PM
  • I'll give it a try.  Thanks for the quick response!
    Tuesday, February 26, 2019 3:32 PM