Hi @Cherry P ,
According to your description, task scheduler is a Windows-related app, not my field of expertise, so I added a Windows-related tag. Regarding your question, from the perspective of SharePoint, it is completely feasible to upload files from local drive to SharePoint through PowerShell. I can provide the code for you to try, but how to combine it with the Task Scheduler to achieve automatic upload requires a reply from a Windows expert.
Here is the code:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Function to Upload File
Function Upload-AllFilesFromDir($WebURL, $DocLibName, $FolderPath)
{
#Get the Web and List to upload the file
$web = Get-SPWeb $WebURL
#Get the Target Document Library to upload
$List = $Web.GetFolder($DocLibName)
#Get the Files from Local Folder
$Files = Get-ChildItem $FolderPath #You can filter files by: -filter “*.pdf”
#upload the files
Foreach ($File in $Files)
{
#Get the Contents of the file to FileStream
$stream = (Get-Item $file.FullName).OpenRead()
# Set Metadata Hashtable For the file - OPTIONAL
$Metadata = @{"Country" = "United States"; "Domain" = "Sales"}
#upload the file
$uploaded = $List.Files.Add($File.Name, $stream, $Metadata, $TRUE)
#dispose FileStream Object
$stream.Dispose()
}
}
#call the upload function
Upload-AllFilesFromDir "https://SharePoint.crescent.com/sites/sitename/" "Shared Documents" "c:\Documents\"
For more details, please refer to:
https://www.sharepointdiary.com/2012/10/bulk-upload-files-to-sharepoint-using-powershell.html
And here is a similar post for your reference:
Hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.