Run an Azure PowerShell Script in Core-edition, gives error for Login-AzureRmAccount

I want to run an Azure PowerShell Script in Core-edition, using the PowerShell Edition feature, but I get the following messages in the log:

Name Value

PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion 2.3
WSManStackVersion 3.0
PowerShell Environment Information:
OperatingSystem: Microsoft Windows NT 6.3.9600.0
OsBitVersion: x64
Is64BitProcess: True
ProcessorCount: 4
HostProcess: pwsh (1728)
TotalPhysicalMemory: 12582452 KB
AvailablePhysicalMemory: 5295536 KB

CloseError: Could not load type ‘System.Security.Cryptography.SHA256Cng’ from assembly ‘System.Core, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089’.
At D:\Octopus\Work\20201020095101-397065-26513\Octopus.AzureContext.ps1:90 char:13

  •         Login-AzureRmAccount -Credential $creds -TenantId $Octopu . 
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

at , D:\Octopus\Work\20201020095101-397065-26513\Octopus.AzureContext.ps1: line 90
at Execute-WithRetry, D:\Octopus\Work\20201020095101-397065-26513\Octopus.AzureContext.ps1: line 49
at , D:\Octopus\Work\20201020095101-397065-26513\Octopus.AzureContext.ps1: line 62
at , D:\Octopus\Work\20201020095101-397065-26513\Bootstrap.Octopus.AzureContext.ps1: line 2029
at , : line 1
at , : line 1

Seems Login-AzureRmAccount is not working in PS 7… it seems you need to do first ‘Import-Module -Name AzureAD -UseWindowsPowerShell’, to be able to use that cmdlet in PS 7.
However I can’t seems to find a way to force that import-command before the Login-AzureRmAccount-command is done by the built-in Octopus script.

Any help or any idea’s?
Br, J

Hi J,

Thanks for reaching out.

Could I please get a bit more information so I can try to reproduce the issue on my end? Could I please get the version of Octopus you’re running, the version of the Tentacle/Worker, as well as the JSON of the step or screenshots?

Please let me know if you have any questions.



We are on this LTS: image001.png

The step is run on the Octopus Server.

It is the last step with name “Cloud - Azure - Setup API Management DOTS”… see in attachment the JSON…

BTW: I was able to “fix” the issue by doing “Enable-AzureRmAlias -Scope LocalMachine” in the PowerShell Core-edition for the Az-modules.




deploymentprocess-Projects-3743.json (12.4 KB)

Hi Joram,

Thanks for the information.

I went ahead and reproduced your scenario on latest and I am getting the same results. I’m going to have a discussion with the product team if its intentional behavior for core.

Please let me know if you have any questions in the meantime.



Thanks, no additional questions.

Waiting for your feedback…



Hi Joram,

Thanks for your patience on this.

Here is an issue so you can track the progress of the resolution:

Please let me know if you have any questions or concerns.


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.