Thursday, January 16, 2014

Run multiple .PS1 scripts when launching PowerShell

  • In the "-command" argument block, a semicolon is an end-of-line delimiter, similar to C#
  • Each line in the "-command" argument block is executed as if it were typed inside the PowerShell interface

Full command to load the Exchange console plus an additional script:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer;Set-AdServerSettings -ViewEntireForest $True; C:\custom\scripts\Script2.ps1"

Scripting with the Exchange Management Shell