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.

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.