Add a parameter.
param (
[string]$path = '' # analyze this csv
)
if ($path -eq '') {
"Please specify the path to a csv to analyze."
return
}
if (!(Test-Path $path)) {
"This file does not exist $path "
return
}
try {
$csv = Import-Csv $path -ErrorAction Stop
$csv.count
} catch {
"Error, unable to access $path"
}