Using a script to bulk create folders in SharePoint using the Resolve-PnPFolder cmd and trying to also update a specific column for the new folders.
The CSV has two columns: FoplderSiteRelativeURL and RDO (RDO is what I’m trying to update)
#Config Variables
$SiteURL = "https://xxxxxxxxxx.sharepoint.com/teams/GroupName"
$CSVFilePath = "C:TempFolders.csv"
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the CSV file
$CSVFile = Import-Csv $CSVFilePath
#Read CSV file and create folders
ForEach($Row in $CSVFile)
{
#Create Folder if it doesn't exist
$newfolder = Resolve-PnPFolder -SiteRelativePath $Row.FolderSiteRelativeURL | Out-Null
$newfolderid = Get-PnPListItem -list Documents -id $newfolder.id
Set-PnPListItem -list Documents -identity $newfolderid.id -values @{"RDO" = $row.RDO}
Write-host "Ensured Folder:"$Row.FolderSiteRelativeURL -f Green
}
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
The above code gives me the following error:
Error: Cannot bind parameter ‘Id’ to the target. Exception setting “Id”: “Cannot convert null to type “System.Int32″.”