What Is Param in Powershell?

What Is Param in Powershell?

The PowerShell parameter is a fundamental component of any script. A parameter is a way that developers enable script users to provide input at runtime. If a PowerShell script's behavior needs to change in some way, a parameter provides an opportunity to do so without changing the underlying code.

What is the use of param in PowerShell?

Adding PowerShell parameters to your scripts allows you to turn your static, single-purpose scripts into tools that can be used on multiple options and resources. Rather than hard coding your scripts with specific values, you can add parameters that turn your scripts into dynamic tools.

How do I set parameters in PowerShell?

To create a parameter set, you must specify the ParameterSetName keyword of the Parameter attribute for every parameter in the parameter set. For parameters that belong to multiple parameter sets, add a Parameter attribute for each parameter set.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.