Solved

How To Include Argument in PowerShell CmdLet

Posted on 2011-02-18
2
1,572 Views
Last Modified: 2012-05-11
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 mickey@domain.com | 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?

Thanks
0
Comment
Question by:brian_appliedcpu
2 Comments
 
LVL 31

Accepted Solution

by:
MegaNuk3 earned 500 total points
ID: 34928161
Add
-confirm:$false

On the end
0
 
LVL 2

Author Closing Comment

by:brian_appliedcpu
ID: 34928805
So I noticed you are inserting a colon in your argument and that seems to work. That's interesting, b/c I was trying to use the -Confirm argument earlier, but I kept getting an invalid cast type error, which I thought had something to do with the $ sign casting my boolean as a string, instead of a true/false value. But it would not work without the $ sign either. So I gave up and started doing a google search. BTW, I ran Remove-Mailbox -? and reviewed the help content a couple of times, but never found where a colon was to be included in the syntax. But hey it works, so I'm happy.
Thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now