Powershell use SecureString from linux to office365

606 views Asked by At

I have some trouble when I try to use the Exchange powershell commandlet : New-MailUser (doc). More specifically, it's using a SecureString that fails.

My problem is that it works well on my windows dev env, but once it's executed on a Linux, it won't. (both powershell 6. Even tried the 7)

I got the following error :

Session key not available to encrypt secure string

I suppose it's a connection type issue (SSL/TLS) (learn from https://www.cloudflare.com/learning/ssl/what-is-a-session-key/ )

Executed commands :

$session = New-PSSession -ConfigurationName:Microsoft.Exchange -Authentication:Basic -ConnectionUri:https://outlook.office365.com/powershell-liveid/ -Credential $credentials -AllowRedirection
Import-PSSession -Session $session

Invoke-Command -Session $s -ScriptBlock { New-MailUser -Name "Ed Meadows" -ExternalEmailAddress [email protected] -MicrosoftOnlineServicesID ed@tailspintoys -Password (ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force) }

I don't know how to work around this, or what I did wrong...

Any enlightened people to help?

0

There are 0 answers