You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a script that download files from sharepoint site to a local server and log them in a file.
I want to modify this script by delete the sharepoint files 5 second previously copied but i have this error. Thanks for help me :slight_smile:
`Remove-PnPFile : A positional parameter cannot be found that accepts argument 'Documents/Extractions_Test'.
At C:\PS\CopyFromSharePointToLocal_TESTThomas_V1 - Copy.ps1:35 char:5
`# Variable - A modifier selon le contexte
$O365ServiceAccount="xxxxxxxxx"# Your User name
$O365ServiceAccountPwd="xxxxxxxxxx"#Your Password - You can use Get-credentials command as well
$SharePointSiteURL="https://tractafric.sharepoint.com/Intranet/Projets" # Change this SharePoint Site URL
$Logfile="C:\pipe\files\testthomas\log\log_testthomas.txt"
$StartTime = Get-Date # Récupère la date
foreach ($File in $Files) {
# Télécharge les fichiers to Network Shared Path et log le nom des fichiers
"Downloading File $($File.Name)" | Add-Content -Path "C:\pipe\files\testthomas\log\log_testthomas-$($StartTime.ToString("yyyyMMdd")).txt"
Get-PnPFile -Url $File.ServerRelativeUrl -Path $SharedDriveFolderPath -FileName $File.Name -AsFile
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello !
I have a script that download files from sharepoint site to a local server and log them in a file.
I want to modify this script by delete the sharepoint files 5 second previously copied but i have this error. Thanks for help me :slight_smile:
`Remove-PnPFile : A positional parameter cannot be found that accepts argument 'Documents/Extractions_Test'.
At C:\PS\CopyFromSharePointToLocal_TESTThomas_V1 - Copy.ps1:35 char:5
`# Variable - A modifier selon le contexte
$O365ServiceAccount="xxxxxxxxx"# Your User name
$O365ServiceAccountPwd="xxxxxxxxxx"#Your Password - You can use Get-credentials command as well
$SharePointSiteURL="https://tractafric.sharepoint.com/Intranet/Projets" # Change this SharePoint Site URL
$Logfile="C:\pipe\files\testthomas\log\log_testthomas.txt"
$StartTime = Get-Date # Récupère la date
$SharedDriveFolderPath="C:\pipe\files\testthomas"
$SharePointFolderPath="Documents/Extractions_Test"
$env:PNPLEGACYMESSAGE='false'
Sécurisation du mot de passe lors de la connexion
[SecureString]$SecurePass = ConvertTo-SecureString $O365ServiceAccountPwd -AsPlainText -Force
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($O365ServiceAccount, $SecurePass)
Connexion au site SharePoint Online
Connect-PnPOnline -Url $SharePointSiteURL -Credentials $PSCredentials
Lecture des fichiers dans SharePoint Document Library Folder /Extractions Test Thomas B
$Files=Get-PnPFolderItem -FolderSiteRelativeUrl $SharePointFolderPath -ItemType File
Wait for 5 seconds
Start-Sleep -Seconds 5
foreach ($File in $Files) {$File.Name)" | Add-Content -Path "C:\pipe\files\testthomas\log\log_testthomas-$ ($StartTime.ToString("yyyyMMdd")).txt"
# Télécharge les fichiers to Network Shared Path et log le nom des fichiers
"Downloading File $(
Get-PnPFile -Url $File.ServerRelativeUrl -Path $SharedDriveFolderPath -FileName $File.Name -AsFile
}`
Beta Was this translation helpful? Give feedback.
All reactions