If you need to import a large volume of list items from CSV or Excel, for example, when importing Info Directory articles in Origami, use this PowerShell script.
# Change this URL to point to the URL where your Info Directory is located
Connect-PnPOnline -Url "https://[your_tenant].sharepoint.com"
# Change this path to point to CSV version of the List
$CSVData = Import-CSV -path "C:\Users\adminuser\Desktop\Test.csv"
foreach ($row in $CSVData)
{
$tags = $row.Tags.Split(";");
$tagLine = "";
foreach ($tag in $tags)
{
if ($tag.IndexOf(" ") -eq 0)
{
$tag = $tag.Substring(1,$tag.Length-1);
}
$tagLine += '"'+$tag+'", ';
}
$tagLine = $tagLine.Substring(0,$tagLine.Length-2);
Add-PnPListItem -List "Info Directory" -Values @{"Title" = $row.Heading; "InfoPostAttachments"='[{"id":0,"title":"Download or Link","linkUrl":"'+$row.Link+'","openWindow":false}]'; "InfoPostBody"=$row.Description; "InfoPostTags"='['+$tagLine+']'}}
You’ll also notice we have C:\Users\adminuser\Desktop\Test.csv.
Here is what that CSV looks like: