title: Issues with PnP.Powershell Get-PnPfile
body: <p>I have been getting the following error while using the cmdlet <code>Get-PnPFile</code>.</p>
  <blockquote>
  <p>Get-PnPFile : The property or field 'ServerRelativeUrl' has not been
  initialized. It has not been requested or the request has not been
  executed. It may need to be explicitly requested. At line:1 char:1</p>
  <ul>
  <li>Get-PnPFile -Url $fileURL -Path $downloadPath -Filename Leavers.CSV - ...</li>
  <li>
  <pre><code>  + CategoryInfo          : WriteError: (:) [Get-PnPFile], PropertyOrFieldNotInitializedException
    + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Files.GetFile
  </code></pre>
  </li>
  </ul>
  </blockquote>
  <p>The code in question is bellow:</p>
  <pre><code>$siteURL = &quot;https://contoso.sharepoint.com/sites/ExampleSite&quot;
  $fileURL = &quot;/sites/ExampleSite/Path/To/The/File.csv&quot;
  $downloadPath = &quot;C:\Temp&quot;
  
  Connect-PnPOnline -Url $siteURL -Credentials (Get-Credential)
  Get-PnPFile -Url $fileURL -Path $downloadPath -Filename File.CSV -AsFile
  
  </code></pre>
  <p>The odd part is that it has previously worked and even now seems to work intermittently but more often than not it seems to error and I haven't been able to identify a pattern.</p>
  <p>The <code>Connect-PnPOnline</code> command runs without error but doesn't seem to work correctly the majority of the time. I have been using <code>Get-PnPSite</code> to check the connection to the SharePoint site but it doesn't seem to be populating after the connection is made as shown bellow.</p>
  <pre><code>PS C:\Windows\system32&gt; Get-PNPsite
  
  Url                                                     CompatibilityLevel                                                                                                                                                                                       
  ---                                                     ------------------                                                                                                                                                                                       
                                                                                                                                                                                                                                                                   
  </code></pre>
  <p>On the odd occasions when the <code>Get-PnPFile</code> command works the two fields above are populated correctly.</p>
  <p>I have been googling this issue and have found some other people who have had success adding a variable to the start of either the <code>Get-PnPFile</code> cmdlet or the <code>Connect-PnPOnline cmdlet</code> Like so:</p>
  <pre><code>$connection = Connect-PnPOnline -Url $siteURL -Credentials (Get-Credential)
  $file = Get-PnPFile -Url $fileURL -Path $downloadPath -Filename File.CSV -AsFile
  </code></pre>
  <p>But this hasn't worked for me. I have also tried down and upgrading the version of PnP.Powershell From 1.8.0 to 1.8.11 and back down to 1.7.0 but this also hasn't had any effect.</p>
  <p>Hope someone out there has some answers! Thanks in advance</p>