Environment variable update requires Tentacle to be restarted

Hi!
I’m using Octopus Deploy 3.4.15 and I’m creating a process that will install the NServiceBus PowerShell module (https://github.com/particular/NServiceBus.PowerShell/releases/tag/5.2.0).

After it has been installed I can’t seem to import the module until the server has been rebooted or the Tentacle restarted.

The command:
Import-Module NServiceBus.PowerShell

Errors with:
Import-Module : The specified module ‘NServiceBus.PowerShell’ was not loaded because no valid module file was found in
any module directory.

After a reboot this works fine.

Can I restart the Octopus Tentacle during an install (this seems a bad idea to me). Is there another way to save a reboot?

Gruss

Hi,

I suspect your best option in this case is to import the module with the full path rather than trying to refresh PSModulePath:

Import-Module -Name 'C:\Program Files (x86)\Particular Software\PowerShell Modules\NServiceBus.PowerShell'

This worked for me in my testing.

Regards,
Mark

Thanks Mark,

That was my workaround, I was just wondering if there was another way.

Thanks,

Gruss

Hi,

Another option would be to manually refresh the PSModulePath environment variable in your script with something like:

$path = ("Machine", "User" `
    | % { [Environment]::GetEnvironmentVariable("PSModulePath", $_) } `
    | % { $_ -split ';' } `
    | Select -unique) `
    -join ';'

Set-Content -Path "Env:PSModulePath" -Value $path

Then at least you don’t need to know the install path.

Regards,
Mark