Looks like “Connect-OctoServer” does not work if calls are done between ps1 file and psm1 module, is that expected?
Using Octopus-CmdLets 0.4.4 and Powershell 5.1
Test.psm1
function Get-EnvironmentViaModule()
{
"getting all environments..."
Get-OctoEnvironment
}
Test.ps1
Import-Module .\Test.psm1
$ApiKey = "API-xxxx"
$Url = "https://octopus.xxx.com"
Connect-OctoServer -Server $Url -ApiKey $ApiKey
"connected..."
Get-EnvironmentViaModule # this fails - but "Get-OctoEnvironment" works
Execution:
> .\Test.ps1
connected...
getting all environments...
Get-OctoEnvironment : Connection not established. Please connect to your Octopus Deploy instance with
Connect-OctoServer
At C:\Users\andrew\Test.psm1:4 char:5
+ Get-OctoEnvironment
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-OctoEnvironment], Exception
+ FullyQualifiedErrorId : System.Exception,Octopus_Cmdlets.GetEnvironment