Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Powershell input parameter via command line

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 post first appeared on SQLSERVER-DBA.com, please read the originial post: here

Share the post

Powershell input parameter via command line

×

Subscribe to Sqlserver-dba.com

Get updates delivered right to your inbox!

Thank you for your subscription

×