user2916766
user2916766

Reputation: 1

run Powershell script from a batch file

I am trying to run a powershell script from a batch file but is not working. the bat file looks like:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command “. ‘S:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.psc1'; Connect-ExchangeServer -auto; S:\Scripts\EnableTransportRuleWest.ps1"

the error when I ran the bat file is:

the string starting: at line:1 char:75
* . S:\Program files[snip] is missing the terminator '. at line:1 char:146

I do not see what's missing, any idea?

Upvotes: 0

Views: 814

Answers (1)

jscott
jscott

Reputation: 871

Did you copy this command line from a blog? You've "smart" quotes in there.

With normal double/single quotes:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'S:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.psc1'; Connect-ExchangeServer -auto; S:\Scripts\EnableTransportRuleWest.ps1"

Upvotes: 2

Related Questions