Powershell – Parameter switching on command line

So you want to have the parameters for your command line change depending on the parameters you select


    function Start-APIStuff {

            Param (

#define the ParameterSets
#Define which parameters are common to all parameter sets                

#Define the parameters that are unique to each parameter set
#In my case i only want to allow the default windows credentials to be used for windowsauth 
#So credentials parameter is only to get an encrypted credential and then parse it to test for an Invoke-webrequest             
                [Parameter(ParameterSetName='InternalAuth', Mandatory=$true)]
                $Credential = [System.Management.Automation.PSCredential]::Empty
#refer https://duffney.io/addcredentialstopowershellfunctions/#adding-a-credential-parameter about credentials    

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.