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.