Reputation: 945
I'm trying to implement API of our product using Powershell. E.g., I'd like to create a function Remove-OurProductEntity
. This function should have both -ById
and -ByFullPath
parameters to know which entity to delete. They shouldn't be both mandatory, but only one of them.
If user specified one of them in the command line, the second mustn't appear in autocompletion and Powershell shouldn't ask user to define the second. Moreover, if user specified both, function should ask to define the only one.
Is it possible to be done in Powershell? Or I should handle all the logic inside the function? Powershell has really COOL language, and guess, something similar should be.
Upvotes: 2
Views: 114
Reputation: 126842
Parameter sets are your friend.
http://blogs.msdn.com/b/powershell/archive/2008/12/23/powershell-v2-parametersets.aspx
Upvotes: 6