Using Command-Line Arguments

Modifying a script at run time is an important time-saving, labor-saving, and flexibility-preserving technique. In many companies, first-level support is given the ability to run scripts but not to create scripts. The first-level support personnel do not have access to script editors, nor are they expected to know how to modify a script at design time. The solution is to use command-line arguments that modify the behavior of the script. In this manner, the scripts become almost like custom-written utilities that are edited by the user, rather than components that are modified via a series of switches and parameters. An example of this technique is shown in the ArgsShare.ps1 script.

The ArgsShare.ps1 script defines a ...

Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.