Copy a file from a Sharepoint library locally to a computer using Powershell.

Copper Contributor

Hello, I would like to copy a file from a Sharepoint library to a local folder via a Powershell script and later via Intune "Script". I have already successfully established a connection to the sharepoint library on the computer. Unfortunately I can't find the command to copy the file locally under C:\Test.
Below is the working part of the script.

 


Install-PackageProvider -Name NuGet -MaximumVersion 2.8.5.208 -Force

Install-Module -Name SharePointPnPPowerShellOnline -Force -AllowClobber

Import-Module SharePointPnPPowerShellOnline -DisableNameChecking

$siteUrl = "my Sharepoint_URL"
$username = "My_accountname@my_domäne"
$password = ConvertTo-SecureString -String "my_passwort" -AsPlainText -Force
$credentials = New-Object PSCredential -ArgumentList $username, $password

 

This not work

 


$item = Get-PnPTenantSiteItem -List "bibliothekname" -Identity "Dateiname.license"
$content = Get-PnPTenantSiteItemContent -List "bibliothekname" -ItemId $item.Id -Field "FileLeafRef"


$content | Set-Content "$Zielpfad\Dateiname.license" -Encoding Byte

 

Error : Get-PnPTenantSiteItem : The name "Get-PnPTenantSiteItem" was not recognised as the name of a cmdlet, a function, a script file or an executable program.
recognised. Check the spelling of the name or whether the path is correct (if included) and repeat the process.

 

thanks for your support, maybe there is another way to copy data from a sharepoint library ?

 

1 Reply