Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need help getting rid of powershell confirmation

Posted on 2008-10-03
4
Medium Priority
?
664 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Suggested Courses

604 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