Created
June 5, 2019 01:55
-
-
Save fgimian/09dbcee04e7bee37ae331ad1f04e519f to your computer and use it in GitHub Desktop.
How can I allow parameter sets to be optional? :)
This file contains hidden or 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
function Install-File { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true, Position=0)][string]$Path, | |
[Parameter(ParameterSetName='SourcePath')][string]$SourcePath, | |
[Parameter(ParameterSetName='Content')][string]$Content, | |
[Parameter(ParameterSetName='DownloadUrl')][string]$DownloadUrl | |
) | |
# ... | |
} | |
# Valid inputs | |
Install-File -Path C:\myfile.txt # QUESTION: How can I allow this scenario to be accepted? | |
Install-File -Path C:\myfile.txt -SourcePath C:\source.txt | |
Install-File -Path C:\myfile.txt -Content hello | |
Install-File -Path C:\myfile.txt -DownloadUrl http://myfile.txt |
adrian-andersson
commented
Jun 5, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment