Skip to main content

Posts

Showing posts from July, 2022

Download All Files From Library in SharePoint online

 #Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   Function Download-AllFilesFromLibrary() {     param     (         [Parameter(Mandatory=$true)] [string] $SiteURL,         [Parameter(Mandatory=$true)] [Microsoft.SharePoint.Client.Folder] $SourceFolder,         [Parameter(Mandatory=$true)] [string] $TargetFolder     )     Try {                   #Create Local Folder, if it doesn't exist         $FolderName = ($SourceFolder.ServerRelativeURL) -replace "/","\"         $LocalFolder = $TargetFolder + $FolderName         If (!(Test-Path -...

Delete all Items from SharePoint Online List

 Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"       #Config Parameters $SiteURL="SharePoint Site URL" $ListName="List Name" $BatchSize = 500     #Setup Credentials to connect $Cred = Get-Credential     Try {     #Setup the context     $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)     $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)         #Get the web and List     $Web = $Ctx.Web     $List=$web.Lists.GetByTitle($ListName)     $Ctx.Load($List)     $Ctx.ExecuteQuery()     Write-host "Total Number of Items Found in the List:"$List.ItemCount  ...

Copy Items from One List to Another List

 #Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   Function Copy-ListItems() {     param     (         [Parameter(Mandatory=$true)] [string] $SiteURL,         [Parameter(Mandatory=$true)] [string] $SourceListName,         [Parameter(Mandatory=$true)] [string] $TargetListName     )         Try {         #Setup Credentials to connect         $Cred = Get-Credential         $Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)               #Setup the context       ...