Storing and using Variable - Credentials within script

Hi There,

I’m relatively new to Powershell universal. Would appreciate some guidance from any of the gurus out there.

I am assuming I am on the right track.

Scenario: Storing Passwords as Variables(PSCredentials) and using it in Scripts

Step 1: Create new variable, select variable type “secret”
Step 2: Name: TestVar, Username: test@domain.com, Password: Testing123, Vault: BuiltinLocalVault

Step 3: Create new script
Here is where I got stuck.

connect-exchangeonline -Credential $TestVar

I also tried

$TestVar2 = Get-UAVariable -Name ‘TestVar’
connect-exchangeonline -Credential $TestVar2

Both do not seem to work.

What happens when you do this? Does it show an error?

I got the following error.

Method not found: ‘Void Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters…ctor(Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior)’.

I tried to google this and unable to figure out what it means.

Hi mtay,

the way you described using the credential object:

connect-exchangeonline -Credential $TestVar

seems to be correct. I’m using them the same way, with authentication in other modules commands, and it’s working for me. Maybe this is an error from ExchangeOnlineManagement module?

Regards,
zweailltienrger