automate a "Yes" answer on a message box

Welcome Forums General PowerShell Q&A automate a "Yes" answer on a message box

Viewing 3 reply threads
  • Author
    Posts
    • #196124
      Participant
      Topics: 1
      Replies: 2
      Points: -4
      Rank: Member

      Hi All,

      I am trying to automate or bypass a message box for a backup script I have.  Here is the portion of the script that shows a popup box that awaits a user decision.  I want to just answer yes and move forward:

      ### Start Function MessageBox ###
      function MessageBox
      {
      [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | out-Null
      $OUTPUT= [System.Windows.Forms.MessageBox]::Show("Continue With Mailbox Export?" , "Status" , 4)
      if ($OUTPUT -eq "YES" )

      {
      QueueMbx
      }
      {
      }
      Else
      {
      write-host "Quitting ...";break
      }

      }

      ###End Function MessageBox ###

       

      thanks in advance... Fred

    • #196148
      Participant
      Topics: 2
      Replies: 1687
      Points: 3,340
      Helping Hand
      Rank: Community Hero

      When you want to respond always with a "yes" anyway, why you're using the message box at all? Just remove it! 😉

      BTW: When you post code please format it as code ... you might (re-)read the first pinned post of this forum: Read Me Before Posting! You'll be Glad You Did!

    • #196160
      Participant
      Topics: 1
      Replies: 2
      Points: -4
      Rank: Member

      Thanks for the advice, I'll do that for future posts... unfortunately deleting that portion did not solve my issue but I think it's on the right track..I have to see what other function in there i may have inadvertently deleted that caused the process to prematurely close with no result.

    • #196166
      Participant
      Topics: 1
      Replies: 2
      Points: -4
      Rank: Member

      In that messagebox function is referencing queuembx,   farther down in the script I see this which i assume is the reference:

       

      ### Function QueueMbx
      Function QueueMbx {
      
      $c1 = 0
      foreach ($mailbox in $mailboxes) { 
      $c1++
      Write-Progress -Id 0 -Activity 'Mailbox Export' -Status "Queued $($c1) of $($mbxtotal)" -PercentComplete (($c1/$mbxTotal) * 100)
      New-MailboxExportRequest -BatchName $BatchName -Mailbox $mailbox.Alias -Filepath "$($BackupLocation)\$($mailbox.Alias).pst" }
      }
      
      ### End Function QueueMbx
Viewing 3 reply threads
  • You must be logged in to reply to this topic.