troubleshooting Question

Exchange Management Shell Query

Avatar of khanfe
khanfe asked on
ExchangeShell Scripting
13 Comments2 Solutions119 ViewsLast Modified:
Hi Folks,

I'm very new to Exchange, so please excuse if there are obvious mistakes in my approach.

We are currently running Exchange 2010 in our Organisation and I need to create a Scheduled Task to run an Exchange query.  I've tried following the article below to create the task, however I wanted to test the query from the Exchange Management Shell first to see if it works:

The query is specified as part of an Argument in the Scheduled Task as below:

-version 2.0 -NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxJunkEmailConfiguration “feroz.khan” -TrustedSendersAndDomains @{Add=""}"

Should I be able to run the above from the Exchange Management Shell? I ask because I am seeing the following error:

Missing expression after unary operator '-'.
At line:1 char:2
+ - <<<< version 2.0 -NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect
-ExchangeServer -auto; Get-Mailbox -Server slkbrhmbx01 | Select DisplayName,RecipientLimits | Export-CSV C:\Output\MaximumRecipient-Limits.csv -NoTypeInformation"
    + CategoryInfo          : ParserError: (-:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingExpressionAfterOperator
Thomas Wheeler

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros