1

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 ed@tailspintoys.com -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?

Palle Due
  • 5,929
  • 4
  • 17
  • 32
Vitelize
  • 23
  • 3
  • 1
    SecureString uses DPAPI for encryption, which [is not available](https://github.com/PowerShell/PowerShell/pull/9199) in non-Windows platforms. – vonPryz Oct 22 '19 at 12:45
  • Didn't saw that thead, but I can see that it have been "enabled" in ps 6.2. Nothing to workaround this ? – Vitelize Oct 22 '19 at 13:13

0 Answers0