title: Powershell Get-PnPFile Access denied error
body: <p>I'm trying to download a file from a Teams Sharepoint site using Powershell.
  I'm using this code:</p>
  <pre><code>Import-Module SharePointPnPPowerShellOnline 
  
  #Config Variables
  $SiteURL = &quot;https://xxxxxx.sharepoint.com/&quot;
  $FileRelativeURL = &quot;/sites/MyTeam/documents/General/test.pptx&quot;
  $DownloadPath =&quot;C:\temp&quot;
  
  Try {
      #Connect to PNP Online
      Connect-PnPOnline -Url $SiteURL -SPOManagementShell  #Need modern login because of MFA     
      #Get-PnPConnection
      #Get-PnPContext
  
      #powershell download file from sharepoint online
      Get-PnPFile -Url $FileRelativeURL -Path $DownloadPath -Filename &quot;test.pptx&quot; -AsFile
  }
  catch {
      write-host &quot;Error: $($_.Exception.Message)&quot; -foregroundcolor Red
  }
  </code></pre>
  <p>However, when I run this, I always get an error:</p>
  <pre><code>Access denied. You do not have permission to perform this action or access this resource
  </code></pre>
  <p>I am owner of the Team, and the file.
  What kind of permissions do I need for this?</p>
  <p>I've also read on the internet that some people, use slightly different URLs. Like this:</p>
  <pre><code>$SiteURL = &quot;https://xxxxxx.sharepoint.com/sites/MyTeam&quot;
  </code></pre>
  <p>This results in a different error:</p>
  <pre><code>File not found
  </code></pre>
  <p>What am I doing wrong?</p>