Q. If I have a credential object in PowerShell, how can I extract the password of the account stored in the credential?
Dept - PowerShell
A. Credentials are created by passing a username and a secure string containing the password. There may be times when you actually need the plain text password back from the credential — for example, if you need to construct the URL for a GRAPH API call to Azure AD. To access the password is actually very simple, assuming the credential is stored in $cred to access the plain text password use:
Note the username can also be extracted with $cred.Username.
A more general note: credentials are are very useful to connect to resources and they can even be saved as assets in technologies such as Azure Automation. You can then extract the credentials and use them in runbooks.