PowerShell – execute script with arguments

Problem

  • You want to execute PowerShell scripts with arguments.

Solution

$arg1="Something"
$arg2=80
Powershell.exe -NoProfile -ExecutionPolicy Bypass -Command c:\temp\test.ps1 $arg1 $arg2

Explanation

  • NoProfile: PowerShell does not load the user profile. (Documentation)
  • Bypass: Nothing is blocked and no warnings or prompts. (Documentation)
Advertisements

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 )

Google+ photo

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

Connecting to %s