Forum Discussion
Uday Kiran Reddy
Dec 12, 2017Copper Contributor
How to uploads files to OneDrive for Business using Powershell
I tried the sample powershell code in below link, getting error as path not found.
https://community.spiceworks.com/topic/2001221-powershell-script-to-upload-file-to-onedrive-business
Sam...
Uday Kiran Reddy
Dec 15, 2017Copper Contributor
And also I am getting below error if I am uploading files larger than 200 MB.
Exception calling "ExecuteQuery" with "0" argument(s): "The operation has timed out"
At C:\Users\uday-\Desktop\New Text Document (2).ps1:55 char:1
+ $Context.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Manidurai Mohanamariappan
Dec 16, 2017Iron Contributor
Yes, this script only support upto 250 mb size for single file so if you want to upload more than 250mb file size of single file, you can refer the below link.
https://gist.github.com/asadrefai/ecfb32db81acaa80282d
- Uday Kiran ReddyDec 16, 2017Copper Contributor
UploadFileInSlice ($ctx, $libraryName, $fileName, $fileChunkSizeInMB)
What is the $ctx we need to pass?
- Manidurai MohanamariappanDec 16, 2017Iron Contributor
Yes you need to pass the $ctx, $ctx is Client context
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
$ctx.Credentials = $Creds