The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

cswannack (2) [Avatar] Offline
#1
I have searched through the index of the Windows Powershell in Action book and cannot seem to locate how you would pass argument values into a script that you would execute from a windows command line:

Something like

powershell.exe restart_iexplorer.ps1 "-k", "http://amazon.com"

I am sure it is there just not "seeing it".

Thank you.
Kiron (38) [Avatar] Offline
#2
Re: Windows Execution of Scriptfiles and Aurgment Inclusion
If the script is in DOS prompt's current directory type a dot and slash before the script's name, if the script is in another location indicate the path to the script. Your example would executed like:

powershell <pathOfScript> estart_iexplorer -k http://amazon.com

-------------------------------------------------
You can read about Scripts and their Arguments in §7.6; more specifically, §7.6.1 & 7.6.2

To read about calling PowerShell scripts --or commands-- from the DOS prompt, type the following in PowerShell:

powershell -help | more

I would also recommend to read these help contents in PowerShell (type help before each one):
about_escape_character
about_parameter
about_quoting_rules
about_special_characters