Get file (download) from Sharepoint through PowerShell script

Another simple article, which provides a PowerShell script that I need to use to download a file from a Sharepoint site.

So for that we are using the Pnp.Powershell module by giving the Sharepoint online credentials and then we use Connect-PnPOnline function to connect in the account from the PowerShell.

The documentation of this module can be found here: PnP PowerShell Overview | Microsoft Docs
The documentation of this function can be found here: Connect-PnPOnline (PnP.Powershell) | Microsoft Docs

After that we can define the directory where the file is going to be downloaded, the path from Sharepoint where the file is located, and the name of the file itself into variables.

After that we use the Get-PnPFile function, to download the necessary file into the directory you defined before.

Get file (download) from Sharepoint through PowerShell script
PowerShell script example

Again it’s a really simple Powershell solution, and the script of this article can be found on my GitHub reporitory: guimatheus92/Get-File-From-Sharepoint-Online (

I hope you enjoyed this simple solution.

This blog is part of SharePoint Week. For more great content, click here

Check out Guilherme’s website here

About the Author:

Brazilian, engineer and developer well versed in BI, SQL, Data Modelling, Analysis Services, ETL Process, Python, VBA, Power BI, etc. Passionate about technology, who uses agile pratices and decision-making processes data-driven. You can find me in my LinkedIn profile, from my website and also from my Medium profile.


Matheus. G. (2021). Get file (download) from Sharepoint through PowerShell script. Available at: [Accessed: 14th September 2021].

Share this on...

Rate this Post: