I am using Powershell scripting to get data from a sharepoint list which exceeds the threshold of 5000 items.
I want to create a for loop which increments by month and year.
The Code in the for loop would move the source SharePoint list data to target SharePoint list.
I cannot completely move all the data at a time due to the limitations of SharePoint online (threshold).
I also want to ensure that all the data of that particular month gets transferred to the target list. Basically, if a month has more than 5000 items, I want the for loop to run again and move the remaining data.
Again, how should I create the for loop for the same?
Current caml query code without the for loop:
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$Query.ViewXml = "@
<View>
<Query>
<And>
<Gt>
<FieldRef Name='Date' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>2020-12-01T18:37:21Z</Value>
</Gt>
<Lt>
<FieldRef Name='Date' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>2020-12-31T18:37:24Z</Value>
</Lt>
</And>
</Query>
<RowLimit Paged='True'>100</RowLimit>
</View>"
Ask me more questions if needed.