title: Combine a default parameter value with validation via the ValidateScript attribute
body: <p>I have the following PowerShell code to validate user input as a path, if the user didn't enter anything, I am attempting to assign a default value to them. However when I run this, the <code>$filePath</code> variable does not gets assigned any value.</p>
  
  <p>Is there anyway I can change this to have it assigned a default value while the validation is going on?</p>
  
  <p><strong>Code below:</strong></p>
  
  <pre><code>function validatePath {
    Param
    (
        [ValidateScript({
          If ($_ -eq "" -or $_ -eq [String]::Empty) {
              $_ = "C:\Install"
              $True
          }
          ElseIf ($_ -match "^([a-z]:\\(?:[-\\w\\.\\d])*)") {
              $True
          } 
          Else {
              Write-Host "Please enter a valid path,$_ is not a valid path."
              Write-debug $_.Exception
          }
        })]
        [string]$filePath = "C:\Install"
    )
    Process
    {
        Write-Host "The path is "$filePath
    }
  }
  
  validatePath -filePath $args[0] 
  </code></pre>