In this article, we are going to learn how to read a column from CSV file in PnP PowerShell.

hostforlifebanner

Use Case

While working with PowerShell scripting we used to have requirement to read column values from csv file and perform some operation. like bulk update item in SharePoint, Create site collection etc.

Here is the sample CSV file we have   –  SitesToCreate.csv

Columns – Site Title,SiteURL,Template,StorageQuota,Owner,TimeZone,LocId

Script to read CSV file

Using below powershell script code we can read the columns from csv file (SitesToCreate.csv)

Result-

PS C:\Peter\ReadCSV> .\ReadCSV.ps1

SiteName : Devlopment Site

SiteURL : https://advanced365app.sharepoint.com/sites/DevTest

Template : STS#0

StorageQuota : 100

Owner : Peter@advanced365app.onmicrosoft.com

TimeZone : 4

LocId : 1033

SiteName : UAT Site

SiteURL : https://advanced365app.sharepoint.com/sites/UATSite

Template : STS#0

StorageQuota : 100

Owner : Peter@advanced365app.onmicrosoft.com

TimeZone : 4

LocId : 1033