• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

Need help getting rid of powershell confirmation

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
lpenrod
Asked:
lpenrod
  • 2
1 Solution
 
dathhoCommented:
try adding
-confirm no
to your Export-Mailbox cmdlet
0
 
gupnitCommented:
Hi
Add this
"-confirm:$false"
or
"-confirm"false"
Thanks
Niutin
0
 
lpenrodAuthor Commented:
This did it, thanks!

-confirm:$false
0
 
gupnitCommented:

My Pleasure :-) !
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now