Last active
May 30, 2017 17:37
-
-
Save p0rkjello/c377888d6ae45b40311928d59a820a56 to your computer and use it in GitHub Desktop.
PowerShell parameter input by array or file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param( | |
[Parameter(ParameterSetName='Name', Mandatory)] | |
[ValidateNotNullOrEmpty()] | |
[string[]] | |
$servers, | |
[Parameter(ParameterSetName='File', Mandatory)] | |
[ValidateNotNullOrEmpty()] | |
[string] | |
$file, | |
[Parameter(ParameterSetName='Name')] | |
[Parameter(ParameterSetName='File')] | |
[ValidateScript({ | |
if (Test-Path $_) { | |
Throw "File exists: $_"} | |
} | |
$true | |
})] | |
[string] | |
$outfile | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment