How to refresh the environment of a PowerShell session after a Chocolatey install without needing to open a new session
问题 I am writing automated script for cloning GitHub source code to local machine. I failed after installing Git in my script, it asked for close/open powershell. So I am not able to clone code automatic after installing Git. Here is my code: iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) choco install -y git refreshenv Start-Sleep -Seconds 15 git clone --mirror https://${username}:${password}@$hostname/${username}/$Projectname.git D:\GitTemp -q 2>&1