Solved

How To Include Argument in PowerShell CmdLet

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Suggested Solutions

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
To show how to generate a certificate request 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 >> Certificates…

734 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