title: How do I recreate PowerShell $profile variable? It's empty in a custom Host
body: <p>If you implement a custom PowerShell Host with <code>System.Management.Automation</code> (SMA), all of the automatic variables are avaialable, except it seems that <code>$PROFILE</code> is empty. How would one go about recreating it?</p>
  
  <p>Is it always in UserProfile + <code>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1</code>? Or do I need to be worried about it being in other places?</p>
  
  <p>To clarify, I only care about <code>CurrentUserCurrentHost</code> profile.</p>
  
  <h3>Details</h3>
  
  <p>Given this PowerShell script:</p>
  
  <pre><code>Write-Output "_Profiles_" 
  Write-Output "CurrentUserCurrentHost = '$($Profile.CurrentUserCurrentHost)'"
  Write-Output "CurrentUserAllHosts = '$($Profile.CurrentUserAllHosts)'"
  Write-Output "AllUsersCurrentHost = '$($Profile.AllUsersCurrentHost)'"
  Write-Output "AllUsersAllHosts = '$($Profile.AllUsersAllHosts)'"
  </code></pre>
  
  <p>Running it against system PowerShell has the following output:</p>
  
  <pre>_Profiles_
  CurrentUserCurrentHost = 'C:\Users\rob\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'
  CurrentUserAllHosts = 'C:\User\rob\Documents\WindowsPowerShell\profile.ps1'
  AllUsersCurrentHost = 'C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1'
  AllUsersAllHosts = 'C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1'</pre>
  
  <p>Running it with a Custom C# PowerShell Host (a <code>System.Management.Automation.Host.PSHost</code> implementation) shows:</p>
  
  <pre>_Profiles_
  CurrentUserCurrentHost = ''
  CurrentUserAllHosts = ''
  AllUsersCurrentHost = ''
  AllUsersAllHosts = ''</pre>
  
  <h3>Background</h3>
  
  <p><a href="https://github.com/chocolatey/choco/issues/667">https://github.com/chocolatey/choco/issues/667</a></p>
  
  <p>This has been tested in PowerShell v3 / <code>System.Managment.Automation</code> (SMA) v3 but it could easily be proven out in other PowerShell versions.</p>