powershell Exchange - how to run all in one ligne

Hello,

I want execute this comand in my exchange 2013 server:

Search-Mailbox identity mailbox SearchQuery kind:contacts -DeleteContent -confirm:$false -force

I must execut this command by the PowerShell Exchange.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command ". 'D:\Exchange2013\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto -ClientApplication:ManagementShell "

How is it possible to automatized this command by powershell exchange ?

For the moment i must first lunch powershell exchange and after make teh command line.

How do all in the same time ?
thx,

August 12th, 2015 10:50am

How about running Exchange Management Shell directly?

I am not sure what you exactly mean under "automatized" and can assume that you probably want to create a scheduled task http://www.msexchange.org/kbase/ExchangeServerTips/ExchangeServer2013/Powershell/scheduling-exchange-powershell-task.html

Free Windows Admin Tool Kit Click here and download it now
August 12th, 2015 11:18am

Hi,
You may type all required cmdletsin a text file and save it as a .ps1 file. Locate the file in PowerShell and open it
August 12th, 2015 11:20am

Great resolution by ManU
Free Windows Admin Tool Kit Click here and download it now
August 12th, 2015 12:32pm

I will take ManU Philip's suggestion.

August 12th, 2015 11:01pm

In a ps1 i can write  ?

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command ". 'D:\Exchange2013\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto -ClientApplication:ManagementShell "Search-Mailbox identity mailbox SearchQuery kind:contacts -DeleteContent -confirm:$false -force

Free Windows Admin Tool Kit Click here and download it now
August 13th, 2015 4:18am

Hi,

Try this method:

Best Regards.

August 13th, 2015 9:39pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics