Solved

How To Include Argument in PowerShell CmdLet

Posted on 2011-02-18
2
1,577 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A brief introduction to what I consider to be the best editor for PowerShell.
In this video we show how to create an Accepted Domain 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 >> Ac…
In this video we show how to create a mailbox database 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 Servers >> Data…

863 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

20 Experts available now in Live!

Get 1:1 Help Now