validate remote session is still valid in gui

Welcome Forums General PowerShell Q&A validate remote session is still valid in gui

This topic contains 2 replies, has 3 voices, and was last updated by

3 years, 6 months ago.

  • Author
  • #35166

    Topics: 23
    Replies: 151
    Points: 344
    Helping Hand
    Rank: Contributor

    i've just noticed some odd behaviour in a gui i've developed, utilizing msonline

    on intial gui load users are prompted for credentials to authenticate to 365, and it then connects the msolservice

    however after a few hours when the session expires, if you try to utilize any of the 365 functions the entire application crashes.

    In script form i would normally just be prompted for credentials again.

    but this isn't occuring, i'm trying to wrap my head around how to validate that the connection is still valid and if not how to force for credentials to be asked for again

  • #35332

    Topics: 13
    Replies: 4872
    Points: 1,843
    Helping HandTeam Member
    Rank: Community Hero

    What's your GUI running in?

  • #35347

    Topics: 2
    Replies: 29
    Points: 0
    Rank: Member

    Can you just add try..catch in your code? Something like

    get-Mailbox $user
    catch [System.Management.Automation.CommandNotFoundException]
    #Prompt for credential

The topic ‘validate remote session is still valid in gui’ is closed to new replies.