We need to fetch data from one SharePoint list and then update those fields data into another SharePoint list using PnP PowerShell. Can anyone please guide or share PnP script for us? Thanks in advance.
Note: We are using SharePoint Online
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this community$Username='[email protected]'
$Password = '************'
#region Credentials
[SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass)
#endregion Credentials
#connect to hubsite
Connect-PnPOnline -Url 'https://Tenant.sharepoint.com/sites/SitrName' -Credentials $PSCredentials
$OlistItems = Get-PnPListItem -List 'OldList'
foreach($item in $OlistItems) {
#Create object
$itemVal = @{
'Title' = $item['Title']
}
Add-PnPListItem -List 'NewList' -Values $itemVal -ContentType "Item"
}