Solved

Need help getting rid of powershell confirmation

Posted on 2008-10-03
4
654 Views
Last Modified: 2011-09-20
I have a script that cleans up users deleted items folder.

get-user | where-object -filterscript {$_.WindowsEmailAddress -Match "@"} | foreach {
$Email = $_.WindowsEmailAddress
$SamAN = $_.SamAccountName
Export-Mailbox -Identity "$Email" StartDate "01/01/1900" EndDate "06/30/2008" -IncludeFolders '\Deleted Items' -PSTFolderPath "c:\Exmerge\$SamAN.pst" -DeleteContent
}

My problem is that I get the message:
Confirm
Are you sure you want to perform this action?
Exporting mailbox content from the mailbox 'User Name' into .pst file
'c:\Exmerge\UName.pst'. This operation may take a long time to complete.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):

If I choose Yes to all, it just moves one mailbox and then I am prompted again.

How can I add a Yes into the code?
0
Comment
Question by:lpenrod
  • 2
4 Comments
 
LVL 6

Expert Comment

by:dathho
Comment Utility
try adding
-confirm no
to your Export-Mailbox cmdlet
0
 
LVL 32

Accepted Solution

by:
gupnit earned 500 total points
Comment Utility
Hi
Add this
"-confirm:$false"
or
"-confirm"false"
Thanks
Niutin
0
 
LVL 3

Author Closing Comment

by:lpenrod
Comment Utility
This did it, thanks!

-confirm:$false
0
 
LVL 32

Expert Comment

by:gupnit
Comment Utility

My Pleasure :-) !
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now