I was recently reading through a blog by Jeffery Hicks and found a CIM script where he is declaring a Credential parameter with a type adapter like this:
[System.Management.Automation.PSCredential()]$Credential
This has the net effect of accepting a credential object or a string username as input and prompting for a password in the case of the string. I have used if statements in my functions to achieve the same thing but this is far cleaner.
Problem is, I can't explain what it's doing! What exactly is happening by including the parentheses in the type declaration? I'd like to learn more about what's happening here in case I can adopt a similar strategy in other functions or with other types.
Thanks!