Fred Morrison’s Weblog

What Mother Never Told You About SharePoint Workflow

Running PowerShell script file from BAT file

Posted by fredmorrison on 2010-11-18

I’ve seen a lot of information about how to run a PowerShell script from inside a BAT file, but most seem very outdated, using the “&” (ampersand) character together with a difficult to remember set of single and double quotes.   For me at least, the simple answer is something like the following, where we assume parameters are passed into the BAT file via the usual method, via %1, %2, etc.

PowerShell.exe -file c:\someplace\someScript.ps1 %1 %2

Very easy.  No convoluted &.  No complex double-quote characters surrounding single-quoted values.  I hope this helps others who, for whatever reason, have to call a PowerShell script from inside a BAT or CMD file.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.