Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

code before checking command line parameters?

$
0
0

I would like to check if a file exists (that contains command line parameters) before parsing the command line options. If I have the following at the top of my ps1 script:

param (

    [string]$server,

    [string]$username,

  )

Any code before the param will cause the param to throw an error. What I would like to do is check the presence of a file in the current directory. If it's there, skip the parameters, otherwise, continue on. Is there a way to put code before the param call, or does it have to be the first line of the file? 

Thanks!

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles