Solved

Need help getting rid of powershell confirmation

Posted on 2008-10-03
4
658 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
ID: 22635964
try adding
-confirm no
to your Export-Mailbox cmdlet
0
 
LVL 32

Accepted Solution

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

Author Closing Comment

by:lpenrod
ID: 31502834
This did it, thanks!

-confirm:$false
0
 
LVL 32

Expert Comment

by:gupnit
ID: 22657183

My Pleasure :-) !
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
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 >>…
To show how to generate a certificate request 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 Servers >> Certificates…

828 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