Running Connect-AzureAD with the -Credential Parameter Clears the Password Property
When I run Connect-AzureAD with the -Credential parameter and pass in a pscredential object saved in a variable, the password property of the credential object is removed. This only happens to one credential object that I use to connect to Office 365 services in powershell, and only after I run Connect-AzureAD, so I assume that this is a bug with that cmdlet.
This is a problem because I generally save a credential in a variable and then connect and disconnect to various Office 365 workloads such as Exchange Online or Sharepoint. If I connect to AzureAD before the others, then the credential object is not able to be used for those other services.
I've reproed this in PowerShell v5.0 and v5.1.
Jason Eaby commented
Experience the same issue but only on the first run on the Connect-AzureAD command. I have it in a function in my profile that requests my credential each time I run the function. If I run the function, the first time through, the password property is cleared when I call Connect-AzureAD. What's more interesting is if I assign the original variable to a second variable, it clears the password property of both.
However, if I re-run the function, Connect-AzureAD doesn't clear the property on subsequent runs.