Jan 08 2023 02:36 PM
Hello,
I need to update a field of all the items in a Library to a new value.
I am using pnp Powershell and want to continue with pnp please.
My example for testing is below - the result I get it "error"
$items = Get-PnPListItem -List "Documents" -Fields "Title"
Foreach ($item in $items)
{
try
{
(Set-PnPListItem -List "Documents" Identity $item.Id -Values @{"Title" = "NewTitle-Test"})
}
catch
{
Write-Host "error"
}
}
Many thanks
Rosie
Jan 08 2023 11:20 PM
SolutionHi @Rosie Horn
you were missing a "-" in front of the "identity" parameter.... This script works
$items = Get-PnPListItem -List "Documents" -Fields "Title"
Foreach ($item in $items) {
try {
Set-PnPListItem -List "Documents" -Identity $item.Id -Values @{"Title" = "NewTitle-Test" }
}
catch {
Write-Host "error"
}
}
Best Regards,
Sven
Jan 09 2023 10:07 AM - last edited on Nov 09 2023 01:54 AM by Maarten Keuzenkamp
Jan 09 2023 10:07 AM - last edited on Nov 09 2023 01:54 AM by Maarten Keuzenkamp
Jan 08 2023 11:20 PM
SolutionHi @Rosie Horn
you were missing a "-" in front of the "identity" parameter.... This script works
$items = Get-PnPListItem -List "Documents" -Fields "Title"
Foreach ($item in $items) {
try {
Set-PnPListItem -List "Documents" -Identity $item.Id -Values @{"Title" = "NewTitle-Test" }
}
catch {
Write-Host "error"
}
}
Best Regards,
Sven