The following code checks if someone using a function; has entered a saved PScredential, if the function needs to prompt the user for a password, or just uses the users current account. Is there an easier way?
You could check $PSBoundParameters.ContainsKey('parameterName') to see if the parameter was specified. You could also code the parameter definition to accept objects of the type [PSCredential], and mark it as mandatory. That way if a credential isn't specified, the shell will prompt for one.