Hi… I have an Office365 password reset script that takes up to three parameters.
A mandatory userprincipalname, ie. "email@example.com
An optional alternate email address i.e. firstname.lastname@example.org
An optional ticket number of the support ticket.
Usually at the PS command line, I can type:
PS> ./reset-password email@example.com firstname.lastname@example.org 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 email@example.com 3840
Or sometimes I don’t have the ticket ID either.
Is there a way to deal with all three possibilities while avoiding named parameters?
If possible I’d like to avoid having to type.
./reset-password -UPN firstname.lastname@example.org -alternate email@example.com -ticketID 3894
Here is how I’m handling it now. I can either supply all three parameters, or just the one,
and if I just have the one I go and manually clean up the ticket.
[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)