How do you add a parameter in a function to ask for credentials as mandatory.

[parameter (Mandatory=$True)]



I want to use the get-credential

So technically get-credentials is already a function, so making it a parameter in your own function isn’t going to work so well.

Instead you define a parameter as the type “pscredentials” so you can use your function with get-credentials. It will behave in a more predictable manner for others instead of calling “get-credentials” in your function. Example:

param (

Now you have a mandatory parameter that ONLY accepts proper credentials.