Some times when you are create a script you need to store some credentials for a specific command to work like connection to Azure or Office 365 storing the password in a file or in the script has always been something you just dont do. That is where leveraging the windows credential manager can be handy though PowerShell dosnt have this ability nativly you can get the ability by installing our Credential Management Module from PowerShell Gallery by running
once installed you can store a credential with the Add-StoredCredentials comment and call it with the Get-StoredCredentials command
One thing to keep in mind the credentials are stored on a per user basis which means the PowerShell console needs to be running as the user that wrote the credentials to Windows Credential Manager.
For more information about Credential Manamgment Please see