I'm having troubles to find a way to get git and poshgit working after installing it through a script using chocolatey without closing the powershell console.
Here is what my script currently looks like.
Function InstallChocolatey {
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
refreshenv #needed to make poshgit install succesfully without restarting Powershell
Write-Output "Chocolatey installed and configured."
}
Function InstallSoftware {
choco install git --params='/NoShellIntegration' -y
choco install poshgit -y
. $profile #reload profile
Write-Output "Software installed and profile reloaded"
}
InstallChocolatey
InstallSoftware
When I close Powershell and restart it everything works as expected. But as my script should later continue executing git stuff I would really like to find a solution to make it work without closing the Console.
From what I found on Stackoverflow and other sites using
. $profile
should reload the Profile. But unfortunately I my case it doesn't seem to have any effect. I tried to use refreshenv again.
My profile file currently only contains one line
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-a4faccd\src\posh-git.psd1'
I also tried adding -force at the end of the line but nothing changed.
I'm pretty new to Powershell, so please bear with me... :)