How To Include Argument in PowerShell CmdLet
Posted on 2011-02-18
I believe that what I want to accomplish is probably simple, but how to do what I want elludes me. I have tried some suggestions found during a google search, but they have not done what I had hoped.
I am using the cmdlet Remove-Mailbox in Exchange PowerShell 2010. The most basic syntax for the cmdlet is:
Remove-Mailbox -Identity <MailboxIdParameter>
Our environment supports multiple organizational units and since the Remove-Mailbox cmdlet does not support the -Organization argument, I am using the following cmdlet to specify the OU and ID, and piping the results to Remove-Mailbox:
[PS]>Get-Mailbox -Organization MyOrg -Identity firstname.lastname@example.org | Remove-Mailbox
The above cmdlet works, but with each ID that has to be removed, I am prompted by PowerShell to confirm my action. Powershell displays the following message with each execution of the above cmdlet:
Are you sure you want to perform this action?
Removing mailbox "domain.com/Microsoft Exchange Organizations/database-mailbox/Mickey" will remove the Active Directory user object and mark the mailbox and the archive (if present) in the database for removal.
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"):
The cmdlet waits for me to select one of the values in brackets. I always press Y. I want to be able to include the default Y in the above cmdlet. How do I do that?