title: Installing PowerShell module persistently for all users
body: <p>I'm installing a PowerShell module via <a href="http://octopusdeploy.com/" rel="nofollow noreferrer">Octopus Deploy</a> onto a number of different servers. For testing purposes, I went with the guidance of Microsoft's documentation for <a href="https://docs.microsoft.com/en-us/powershell/scripting/developer/module/installing-a-powershell-module" rel="nofollow noreferrer">installing PowerShell Modules</a>.</p>
  <p>This worked fine, but as the documentation stated, my changes would be visible only for the current session. That is, if I were to do the following:</p>
  <pre><code>$modulePath = [Environment]::GetEnvironmentVariable(&quot;PSModulePath&quot;, [EnvironmentVariableTarget]::Machine)
  # More practically, this would be some logic to install only if not present
  $modulePath += &quot;;C:\CustomModules&quot;
  [Environment]::SetEnvironmentVariable(&quot;PSModulePath&quot;, $modulePath, [EnvironmentVariableTarget]::Machine)
  </code></pre>
  <p>When running this installer automatically on tentacle servers, future PowerShell sessions do not appear to see the newly installed modules.</p>
  <p>How can I install a PowerShell module in a profile agnostic way so that every PowerShell session started can see it?</p>