07-08-2019 01:08 PM
07-08-2019 01:08 PM
I have a script that I found in many forms online that I re-tooled to work in my environment.
The purpose of the script is to copy files from local File Server to a Library on my SharePoint Online.
I have it working to the site I want it to go to as long as the site's "Members Group" has Write Access to the sub directory. in this scenario, I need to limit access to this library and don't want the Sites "Members Group" to have access.
when I remove the "Members Group" and add explicit permissions for the Licensed O365 User that executes the upload, I get these errors:
You cannot call a method on a null-valued expression.
At C:\TESTMove_file.ps1:70 char:5
+ $FileUploaded = $FolderToUpload.Files.Add($FileCreationInfo)
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Cannot find an overload for "Load" and the argument count: "1".
At C:\TESTMove_file.ps1:73 char:2
+ CategoryInfo : NotSpecified: (:) , MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an
error: (401) Unauthorized."
At C:\TESTMove_file.ps1:74 char:5
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : WebException
I haven't been able to find a reason this wouldn't work? Please advise.
07-14-2019 06:52 PM
Did you give these named users Contribute or Edit permissions? The members group has Edit by default and I've seen strange behavior if you drop to Contribute.
07-17-2019 09:16 AM
yes the User that I use to Connect to Sharepoint is in the "Owners" group for that document library.
I have even explicitly granted it Full control over the library.
07-17-2019 10:44 AM
Besides the script, was there a reason why you weren't using the free SharePoint migration tool to migrate the files instead of the script?
07-17-2019 01:23 PM
Yeah, trying to automate it, schedule it for when a file is created in the on prem directory.