Forum Discussion
Import items from a CSV file to a Sharepoint Online list
WARNING: The names of some commands imported from the "Microsoft.Online.Sharepoin" module
t.PowerShell" contain untrusted verbs which may make them less detectable. Po
To find commands with untrusted verbs, run the Import-Modu command again
le with the Verbose parameter. To get a list of approved verbs, type Get-Verb.
COMMENTS: The "Upgrade-SPOSite" command in the "Microsoft.Online.Sharepoint.Power" module
rShell" was uploaded, but since its name does not contain an approved verb, it p
was hard to find. To get the list of approved verbs, type Get-Verb
.
COMMENTS: Imported "Upgrade-SPOSite" cmdlet.
COMMENTS: The "Verify-SPOCrossTenantRelationship" command in the "Microsoft.Onli" module
ne.Sharepoint.PowerShell" was imported, but since its name does not contain a verb
approved, it may be difficult to find. Suggested replacement verbs are
"Test".
COMMENTS: Imported "Verify-SPOCrossTenantRelationship" cmdlet.
Get-SPOUser: Could not find a parameter matching the name 'Identity'.
To character
C:\Users\aaaaaaaaaaaaaaaaa\Documents\PowerShell\Export_CSV_to_Sharepoint.ps1:33:35
+ $item["Manager"] = Get-SPOUser -Identity $row.Manager -web "https: ...
+ ~~~~~~~~~
+ CategoryInfo: InvalidArgument: (:) [Get-SPOUser], ParameterBindingException
+ FullyQualifiedErrorId: NamedParameterNotFound,Microsoft.Online.SharePoint.PowerShell.Ge
tSPOUser
Harm_Veenstra
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
- 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>