Solved

Need help getting rid of powershell confirmation

Posted on 2008-10-03
4
660 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
In-place Upgrading Dirsync to Azure AD Connect
In this video we show how to create a Shared Mailbox 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 >> Sha…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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