At this point all processing of the function is complete.
if ($CSVUPath -eq ??????)
{
$notValidPath = $true
Write-Host -fore yellow ???`nYou must enter the full path to a CSV file to
use as input to this script.`n???
return $notValidPath
}
If the first conditional test evaluates to false , then at least some value was passed at the command line.
But is that value a valid path to a file? To find out, the next command is an if statement that uses
the Test-Path cmdlet to test the path stored in $CSVUpath to see if it resolves to an existing file. The
PathType parameter specifies a leaf object, which corresponds to a file type as opposed to a
container object, which is a directory type. That prevents the user from entering only a path to a
directory and not the full path to a file.
Chapter 15: User, Group, and Public Folder Administration
437
The result of running Test-Path is True if the file is found and False if the file is not found. Because
an if statement only executes the contents of the code block when the conditional test is True , the result
of the Test-Path command must be changed to True if the file was not found. To accomplish this, the
conditional test has been wrapped by parentheses and the NOT operator ( ! ) is used to change the result
of the test to the opposite value; true becomes false and false becomes true.
Pages:
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598