Skip to content

Instantly share code, notes, and snippets.

@p0rkjello
Last active May 30, 2017 17:37
Show Gist options
  • Save p0rkjello/c377888d6ae45b40311928d59a820a56 to your computer and use it in GitHub Desktop.
Save p0rkjello/c377888d6ae45b40311928d59a820a56 to your computer and use it in GitHub Desktop.
PowerShell parameter input by array or file.
[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