14 December,2017 by Tom Collins
Question: How do you use input parameters on Powershell via command line? I need to pass a value
Answer: The easiest way to use input parameters on Powershell via command line is to use this method. This method will give you the flexibility to use multiple input parameters in your powershell scripts
First , let's look inside the script:
param ( [string]$myserver = "http://myserver" ) write-output $myserver
This script accepts an input parameter - which you'll call from the command line. In this case , you'll pass in a parameter call "myserver" and then it will output to the console. If you don't pass in a parameter - the default value "http://myserver" will be written.
.\parameters.ps1 -myserver http://www.sqlserver-dba.com.com
Read more on Powershell input parameter via command line
Powershell - run script on all sql servers (SQL Server DBA)
Read a script file into Powershell CommandText with get-content ...
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |