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:
In the cmd did you type powershell.exe -version 2.0 .... ? See the task scheduler runs via a cmd so you command is starting a powershell from a cmd with the -version 2.0 option. Is that making sense?
Thomas Wheeler
It looks like you are missing the powershell.exe part of the command
The first part just starts powershell from a cmd prompt and runs the remote exchange powershell script. This loads the exchange module so you can run the cmd. It's like opening the exchange management console on the server
khanfe
ASKER
Exactly, so I can run the following command directly from the Exchange Management Shell successfully
The reason for that is when you have a scheduled task you do not want it popping up windows when it runs
khanfe
ASKER
Thanks for your assistance! - I seem to be getting a little further.
Just as you mentioned, it starts powershell from a cmd prompt and runs the remote exchange powershell script. It did however come back with the following errors?
Qlemo
Execution of parts of the script are denied because they are not signed, and execution policy requires that. So we have to bypass the policy (no restrictions).
powershell.exe -version 2.0 -NonInteractive -WindowStyle Hidden -ExecutionPolicy ByPass -command # and so on ...
-version 2.0 -NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExcha
Command Prompt response:
=======================
'-version' is not recognized as an internal or external command,
operable program or batch file.
Powershell response:
=================
Missing expression after unary operator '-'.
At line:1 char:2
+ - <<<< version 2.0 -NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bi
n\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Set-MailboxJunkEmailConfig
omains @{Add="grey.black@def21.co
+ CategoryInfo : ParserError: (-:String) [], ParentContainsErrorRecordE
+ FullyQualifiedErrorId : MissingExpressionAfterOper