title: How to refresh the environment of a PowerShell session after a Chocolatey install without needing to open a new session
body: <p>I am writing automated script for cloning GitHub source code to local machine.<br>
  I failed after installing Git in my script, it asked for close/open powershell.<br>
  So I am not able to clone code automatic after installing Git.</p>
  
  <p>Here is my code:</p>
  
  <pre><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&gt;&amp;1 | %{ "$_" } 
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>git : The term 'git' is not recognized as the name of a cmdlet, 
        function, script file, or operable program. 
        Check the spelling of the name, or if a path was included, 
        verify that the path is correct and try again.
  </code></pre>
  
  <p>Please let me what should I put for reboot PowerShell without exiting? </p>