Calling a Powershell script with multiple parameters

If you are working with a PowerShell​ script that takes parameters and some of those parameters contain spaces you can call the script as follows.

powershell “& {&’C:\Users\<user folder>\Documents\BackupFiles.ps1′ ‘\\server\share\a folder with spaces’ ‘\\server\share\another folder with a space’}”

The first value passed after the -command is the ps1 script and then the parameters the script takes are passed, but they are enclosed in single quotes.

The initial “&{& and the closing } are the important points to note.

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