0

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

1 Answer 1

0
$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"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.