automate a "Yes" answer on a message box

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

When you want to respond always with a “yes” anyway, why you’re using the message box at all? Just remove it! :wink:

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!

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.

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