Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dev-kperera/de1a9f8eaf0b65da199bfed63fc4d16c to your computer and use it in GitHub Desktop.
Save dev-kperera/de1a9f8eaf0b65da199bfed63fc4d16c to your computer and use it in GitHub Desktop.
Using SharePointPnP.PowerShell modules.
# variables
$siteURL = "https://org.sharepoint.com/sites/siteName"
$sharePointAdminUser = 'admin@org.onmicrosoft.com'
$cred = Get-Credential -UserName $sharePointAdminUser -Message 'Connect with a user with global level permissions'
# connect
Connect-PnPOnline -Url $siteURL -Credentials $cred
# Import values from CSV
$path = ".\source.csv"
$rows = Import-Csv $path
# loop thru lines in CSV file
ForEach ($row in $rows) {
$val1 = $row.ColumnTitle1
#
#
$valN = $row.ColumnTitleN
Add-PnPListItem -List "List Name" `
-Values @{
"ColumnIdentifier1" = "$val1";
"ColumnIdentifier2" = "$val2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment