I am by no means a programmer, but I was approached with the task of moving files from a specific date range from a remote server to a SharePoint site. Currently the script that I've been working on just displays the files within the specific date range, but doesn't copy those files from the remote server to the SharePoint site. If anyone can take a look at this and let me know what I'm missing I would greatly appreciate it!
$URL = "designated url"
#First time tasks
#Install-Module SharePointPnPPowerShellOnline
$Creds = get-credential
Add-PnPStoredCredential -Name $URL -Username $Creds.Username -Password $Creds.Password
import-module SharePointPnPPowerShellOnline -Verbose
Connect-PnPOnline $URL -UseWebLogin
#Enter the name of the folder at the end of PAMInvoices
$Files = Get-ChildItem "filepath"
if ($Files = {$_.lastwritetime -gt ‘1/1/11’ -AND $_.lastwritetime -lt ‘1/1/15’})
{foreach($File in $Files)
{#$File = $Files[0]
Add-PnPFile -Folder $URL -Path $File.FullName}}