After an update to 3.17.5 from 3.17 none of our Azure power shell scripts run, We get errors such as
“The term ‘Get-AzureRmEnvironment’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again”
or
The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: The required module ‘AzureRM.Profile’ is not loaded. Load the module or remove the module from ‘RequiredModules’ in the file ‘C:\Octopus\Calamari\Azure\3.7.106\PowerShell\Storage\Azure.Storage\Azure.Storage.psd1’.
Everything was working fine before the Octopus update. All tentacles have been updated and the server rebooted.
Logs:
Failed: Octopus Server
17:05:20 Verbose | Octopus Server version: 3.17.5+Branch.master.Sha.e4f297584b37ff1c37de4043c8bec35df19300dc
17:05:20 Verbose | Environment Information:
| OperatingSystem: Microsoft Windows NT 6.3.9600.0
| OsBitVersion: x64
| Is64BitProcess: True
| CurrentUser: NT AUTHORITY\SYSTEM
| MachineName: SOFTDEV-DPLY01
| ProcessorCount: 1
| CurrentDirectory: C:\Windows\system32
| TempDirectory: C:\Windows\TEMP
| HostProcessName: Octopus.Server
| PID: 1240
17:05:20 Verbose | Using account ID 'Azure Lower Principal’
17:05:21 Verbose | Octopus Deploy: Calamari.Azure version 3.7.106
17:05:21 Verbose | Environment Information:
17:05:21 Verbose | OperatingSystem: Microsoft Windows NT 6.3.9600.0
17:05:21 Verbose | OsBitVersion: x64
17:05:21 Verbose | Is64BitProcess: True
17:05:21 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
17:05:21 Verbose | MachineName: SOFTDEV-DPLY01
17:05:21 Verbose | ProcessorCount: 1
17:05:21 Verbose | CurrentDirectory: C:\Octopus\Work\20171005160520-26733-5
17:05:21 Verbose | TempDirectory: C:\Windows\TEMP
17:05:21 Verbose | HostProcessName: Calamari.Azure
17:05:21 Verbose | Executing 'C:\Octopus\Work\20171005160520-26733-5\Script.ps1’
17:05:23 Verbose | Name Value
17:05:23 Verbose | ---- -----
17:05:23 Verbose | PSVersion 4.0
17:05:23 Verbose | WSManStackVersion 3.0
17:05:23 Verbose | SerializationVersion 1.1.0.1
17:05:23 Verbose | CLRVersion 4.0.30319.42000
17:05:23 Verbose | BuildVersion 6.3.9600.18773
17:05:23 Verbose | PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
17:05:23 Verbose | PSRemotingProtocolVersion 2.2
17:05:23 Verbose | PowerShell Environment Information:
17:05:23 Verbose | OperatingSystem: Microsoft Windows NT 6.3.9600.0
17:05:23 Verbose | OsBitVersion: x64
17:05:23 Verbose | Is64BitProcess: True
17:05:23 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
17:05:23 Verbose | MachineName: SOFTDEV-DPLY01
17:05:23 Verbose | ProcessorCount: 1
17:05:23 Verbose | CurrentDirectory: C:\Octopus\Work\20171005160520-26733-5
17:05:23 Verbose | CurrentLocation: C:\Octopus\Work\20171005160520-26733-5
17:05:23 Verbose | TempDirectory: C:\Windows\TEMP
17:05:23 Verbose | HostProcessName: powershell
17:05:23 Verbose | TotalPhysicalMemory: 2096692 KB
17:05:23 Verbose | AvailablePhysicalMemory: 447596 KB
17:05:23 Verbose | Adding bundled Azure PowerShell modules to PSModulePath
17:05:24 Info | Attempt 1 of 5 failed: The term ‘Get-AzureRmEnvironment’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
17:05:24 Info | Waiting for 5 seconds before retrying…
17:05:28 Info | Retrying…
17:05:29 Info | Attempt 2 of 5 failed: The term ‘Get-AzureRmEnvironment’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
17:05:29 Info | Waiting for 5 seconds before retrying…
17:05:34 Info | Retrying…
17:05:34 Info | Attempt 3 of 5 failed: The term ‘Get-AzureRmEnvironment’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
17:05:34 Info | Waiting for 5 seconds before retrying…
17:05:39 Info | Retrying…
17:05:39 Info | Attempt 4 of 5 failed: The term ‘Get-AzureRmEnvironment’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
17:05:39 Info | Waiting for 5 seconds before retrying…
17:05:44 Info | Retrying…
17:05:45 Error | Get-AzureRmEnvironment : The term ‘Get-AzureRmEnvironment’ is not recognized
17:05:45 Error | as the name of a cmdlet, function, script file, or operable program. Check the
17:05:45 Error | spelling of the name, or if a path was included, verify that the path is
17:05:45 Error | correct and try again.
17:05:45 Error | At C:\Octopus\Work\20171005160520-26733-5\Octopus.AzureContext.ps1:67 char:29
17:05:45 Error | + $AzureEnvironment = Get-AzureRmEnvironment -Name
17:05:45 Error | $OctopusAzureEnvironmen …
17:05:45 Error | + ~~~~~~~~~~~~~~~~~~~~~~
17:05:45 Error | + CategoryInfo : ObjectNotFound: (Get-AzureRmEnvironment:String)
17:05:45 Error | [], ParentContainsErrorRecordException
17:05:45 Error | + FullyQualifiedErrorId : CommandNotFoundException
17:05:45 Verbose | Updating manifest with output variables
17:05:45 Verbose | Updating manifest with action evaluated variables
17:05:45 Fatal | The remote script failed with exit code 1
17:05:45 Verbose | at Octopus.Worker.Scripting.ScriptResult.EnsureSuccessful()
| at Octopus.Server.Orchestration.Deploy.Azure.AzureActionHandlerBase.Execute(ActionCommand command, Machine machine)
| at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.<>c__DisplayClass29_0.b__0()
| at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.ExecuteWithTransientErrorDetection(Action action, Machine machine)
| at Octopus.Server.Orchestration.Deploy.DeploymentTaskController.ExecuteActionAndInitLoggingContext(PlannedStep step, Machine machine, PlannedAction action)
17:05:45 Fatal | create-resource-group on the Octopus Server