Forum Discussion
Import items from a CSV file to a Sharepoint Online list
But the syntax to get the user should be:
Get-SPOUser -Site "xxx" -LoginName "xxx"
For your CSV import you could do something like:
$processinglist = Import-Csv -path $Filepath1 -Delimiter ";"
forEach ($NameValue in $processinglist){
[string]$LoginName= $($NameValue.UPN).Trim
# .... do some magic
}
#disconnect
Thanks, when I use your technique I have no errors! On the other hand my items in my SharePoint list coming from my CSV file are empty 😞 Why I don't have my values displayed 😧 ?
- Micca0815Apr 06, 2022Iron Contributor
Looking at one of the screenshots you have provided I would suggest to tackle multiple potential issues as follows:
1) ensure proper encoding of you input
(not seen anywhere in this thread, but just to be on the save side keep it for later in mind).
What I definitely could not see in your screenshot is the property for the delimiter of your CSV data#Get Import , convert to UTF $NewFile = $ImportFile.Replace(".csv","UTF.csv") Type $ImportFile -Encoding:String | Out-File $NewFile -Encoding UTF8 Start-Sleep -Seconds 2 #Import the new created file $data = Import-Csv -path $NewFile -Delimiter "`t" # ";" start-sleep -Seconds 5 #delete the new created file again remove-item -path $NewFile
2) Within the Foreach put some additional brackets around the CSV column names:
$item['Title'] = $($row.ColumnHeader)
Whereby if the header consists of multiple lines or white spaces you might want to define the column header beforehand:
variation 1:
(spacing)$TitleHeading = "Nom Prenom"
[STRING]$MyTitle = $($row.$TitleHeading).trim()
$item['Title'] = $MyTitlevariation 2:
(whoever thought having multiple lines within the header is a good idea 😉 )
$TitleHeading = @"
Nom Prenom
(obligatoire)"@
[STRING]$MyTitle = $($row.$TitleHeading).trim()
$item['Title'] = $MyTitle<edit 1>:
, had a look at your screenshot to peek on your code just to notice after posting my reply that you have included it now within your initial posting.
</edit>