Quantcast
Channel: Microsoft Online: SharePoint Online forum
Viewing all articles
Browse latest Browse all 10096

To Copy File or Folder of Libruaries with PowerShell in SharePoint Online (Using MoveCopyUtil)

$
0
0

I want to copy File or Folder of Libruary to  Libruary in SharePoint Online with PowerShell.

this code does not work.but it can be compiled.

Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"

function spoCon([string]$siteUrl){
  $context = New-Object Microsoft.SharePoint.Client.ClientContext([string]$siteUrl)
  $username = $global:SPO_USERID
  $password = ConvertTo-SecureString $global:SPO_PASSWORD -asplaintext -force
  $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
  $context.Credentials = $credentials
  return $context
}

function main(){
    $context = spoCon $siteUrl

           [Microsoft.SharePoint.Client.MoveCopyUtil]::CopyFile($context,"[srcURL]","[destURL]",$true)
       [Microsoft.SharePoint.Client.MoveCopyUtil]::CopyFolder($context,"[srcURL]","[destURL]")
       [Microsoft.SharePoint.Client.MoveCopyUtil]::MoveFile($context,"[srcURL]","[destURL]",$true)
       [Microsoft.SharePoint.Client.MoveCopyUtil]::MoveFolder($context,"[srcURL]","[destURL]")

}

or have to download file and upload it?

please help me.


Viewing all articles
Browse latest Browse all 10096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>