title: Insert Username in to file path Powershell
body: <p>We are in the process of trying to tidy up our users home directories and speed up some office 2007 performance by moving all their templates in to a new directory on their user drive (U:).  During my initial tests I can get the below script to work fine though it has the obvious problem of only working for my username.  Is there a way to get it to take the currently logging in user?  Before this would be handled by %username% and from a brief scan of the internet apparently:</p>
  
  <pre><code>$[Environment]::UserName 
  </code></pre>
  
  <p>Should work.  However I seem to be getting errors. Is there a better way to achieve the current logging in users name in to the file path?</p>
  
  <pre><code>if (!(Test-Path -path '\\SERVER\PATH\TO FILES\$[Environment]::UserName\Normal\'))
  {
  New-Item '\\SERVER\PATH\TO FILES\$[Environment]::UserName\Normal\' -type directory
  ##Move-Item \\SERVER\PATH\TO FILES\$env:username\Normal.dot \\\SERVER\PATH\TO FILES\$env:username\Normal\
  ## Move-Item \\SERVER\PATH\TO FILES\$env:username\*.dotm \\SERVER\PATH\TO FILES\%username%\Normal\
  }
  else
  {
  "No work to do"
  }
  </code></pre>