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

Check that a filename was passed when you execute ps1

$
0
0

I am very new to ps1 scripting (first day).  Trying something very simple, trying to make sure that a file name is passed when script is executed and if not display a message to the user.

This doesn't appear to work.

param(

[Parameter(ValueFormPipeLine)]

[ValidateNotNullorempty()]

$var1

)

Process

{

  if ($var = " ")

  {

    Throw "You MUST supply a text file."

  }

}

 

Thanks for the pointers in advance.


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images