Hi... I have an Office365 password reset script that takes up to three parameters.
Usually at the PS command line, I can type:
PS> ./reset-password firstname.lastname@example.org email@example.com 3840
But sometimes I don't have the alternate eMail address. I'd like to be able to supply the UPN and the ticket ID only, thereby sliding the ticketID which is usually the third parameter into "second place".
PS>./reset-password firstname.lastname@example.org 3840
Or sometimes I don't have the ticket ID either.
./reset-password -UPN email@example.com -alternate firstname.lastname@example.org -ticketID 3894
Here is how I'm handling it now. I can either supply all three parameters, or just the one,
[Cmdletbinding()] param ( [Parameter(Position=0, mandatory=$True, ValueFromPipeline=$True)] [string] $UpName, [Parameter(Position=1, ValueFromPipeline=$True)] [string] $PrivateEMail, [Parameter(Position=3, ValueFromPipeline=$True)] [string] $FDTicketID)
May I ask what the problem is with providing named parameters?
Well, I'm trying to avoid typing them. I wasn't sure if it was possible to have "shifting positional parameters". (I just made that up).
Or maybe multiple parameter sets which account for the three different possibilities?
You must be logged in to reply to this topic.