title: UnauthorizedAccessException from PowerShell when using Invoke-WebRequest
body: <p>I know that the error is pretty much self-explenatory but yet I am not able to find solution. I write a <code>PowerShell</code> script to automate the set-up project for the dev machines. There are a set of programs that must be installed so what I want to do i first download the file and then install it. I am having problems with downloading file from the web to the local machine.</p>
  
  <p>My logic is as follows. I have an <code>.xml</code> file where I configure all the stuff. For the downloads it looks like this:</p>
  
  <pre><code>&lt;download source="https://github.com/msysgit/msysgit/releases/download/Git-1.9.5-preview20150319/Git-1.9.5-preview20150319.exe"
  destination="C:\Temp" filename="Git-1.9.5-preview20150319.exe"/&gt;
  </code></pre>
  
  <p>Then in my <code>PowerShell</code> script file I have this function:</p>
  
  <pre><code>function install-tools() {
  Set-ExecutionPolicy RemoteSigned
  $xmlFileInformation = $config.SelectNodes("/setup/downloads/download");
  Foreach ($file in $xmlFileInformation)
  {
  $("Filename: " + $file.filename)
  $("File source: " + $file.source)
  $("File destionation: " + $file.destination)
  
      $("****************************************************************");
      $("*** Downlading "+ $file.filename);
      $("****************************************************************");
      Invoke-WebRequest $file.source -OutFile $file.destination
  
  }
  
  $("Task finished");
  }
  </code></pre>
  
  <p>After executin I get the error from the title <code>UnauthorizedAccessException from PowerShell when using Invoke-WebRequest</code>. Two things that I can mention is that I have included <code>Set-ExecutionPolicy RemoteSigned</code> and also, I execute the script running <code>PowerShell</code> as administrator. I've tried different paths but it's the same everytime, I don't get permission to write anywhere. The only thing that I can't try is using another drive I have only one - <code>C:\</code>.</p>
  
  <p>And one strange thing - my destination directory is <code>C:\Temp</code> but during one of my attempts I didn't have such a directory in <code>C:\</code> so I ended up with file named <code>Temp</code> in my <code>C:\</code> but this was the closest I get to getting a file. </p>
  
  <p>I don't need to save those files in a particular place since it's very possible to delete the entire directory after successfull set-up so what I need is a way to let powershell save files somewhere in my <code>C:\</code> drive. Since I'm not sure if this is related with administrating my system and setting the correct rights (I tried to lower the protection as much as I can) or I miss something in my <code>PowerShell</code> script?</p>