Import items from a CSV file to a Sharepoint Online list

Copper Contributor

I made a PowerShell script to import items from a CSV file to a Sharepoint Online list. Except that my code does not work because I have this error:  "Get-SPOUser : Le terme «Get-SPOUser» n'est pas reconnu comme nom d'applet de
commande, fonction, fichier de script ou programme exécutable. Vérifiez
l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin
d'accès est correct et réessayez."


My "Manager" item is a People Picker.

Can you help me please :( ?


My code :



#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

##Variables for Processing
$SiteUrl = "https://abc/abc"
$ImportFile ="C:\Scripts\Equipe Romain.csv"
$Password ="1234"
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
$Context.Credentials = $credentials
#Get the List
$List = $Context.web.Lists.GetByTitle($ListName)
#Get the Data from CSV and Add to SharePoint List
$data = Import-Csv $ImportFile
Foreach ($row in $data) {
    #add item to List
    $ListItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
    $Item = $List.AddItem($ListItemInfo)

   $item["Title"] = $row."Nom Prenom" 
   #Set the People Picker Field value
   $item["Manager"] = Get-SPOUser -Identity $row.Manager -web "https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaa/"

   $item["Lundi"] = $row.Lundi
   $item["Mardi"] = $row.Mardi
   $item["Mercredi"] = $row.Mercredi
   $item["Jeudi"] = $row.Jeudi
   $item["Vendredi"] = $row.Vendredi



20 Replies
Did you import the module by installing it from here and by running Import-Module Microsoft.Online.Sharepoint.PowerShell
I just did it, and suddenly now I have this error in addition :( : Import-Module : Le module «Microsoft.Online.Sharepoint.PowerShell» spécifié n'a pas été
chargé, car aucun fichier de module valide n'a été trouvé dans un répertoire de module.
Au caractère
Install-Module Microsoft.Online.Sharepoint.PowerShell does work?
Any error messages when trying to install?
When I install it from the command line nothing happens :
But when I install it from the Microsoft website you sent (by downloading the .msi) it works.
But when I execute my powershell code it doesn't work :( :
If nothing happens/no prompt when running Install-Module Microsoft.Online.Sharepoint.PowerShell , you can add the -verbose parameter to see what it does. (No output while running install-module means that there was no issue)

If you run a import-module Microsoft.Online.Sharepoint.PowerShell -verbose, do you see VERBOSE: Importing cmdlet 'Set-SPOUser'. ?
I have this :

And if I run import-module Microsoft.Online.Sharepoint.PowerShell -verbose I have this :
Could you remove the installed Sharepoint Online Management shell from the add/remove programs and try again without the add-type commands in the top of your script?

Okey ! I have try it but I have this errors :
Could you try this? Cleanup of any previous installations and reinstall
I have try this but I have the same problem ;--;
I did everything that was stated on the forum. So now instead of my old mistakes, I have new ones :
Could you select the text and translate it to English?

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
COMMENTS: Imported "Verify-SPOCrossTenantRelationship" cmdlet.
Get-SPOUser: Could not find a parameter matching the name 'Identity'.
To character
+ $item["Manager"] = Get-SPOUser -Identity $row.Manager -web "https: ...
+ ~~~~~~~~~
+ CategoryInfo: InvalidArgument: (:) [Get-SPOUser], ParameterBindingException
+ FullyQualifiedErrorId: NamedParameterNotFound,Microsoft.Online.SharePoint.PowerShell.Ge




as you make use of CSOM and SharePoint Online Management shell, I`d suggest to download the latest CSOM libraries from here:

and once downloaded load them into your current session.
The installed ones you are adding currently might not be compatible with SharePoint Online.

BTW. , you do not need to install those, they could be filed relative to the scripts´ location as well.
e.g. this is a shortened function I would use.

function get-assemblies {
   $sCSOMPath= $scriptDir       
        $sCSOMRuntimePath=$sCSOMPath +  "\Microsoft.SharePoint.Client.Runtime.dll"         
        $sCSOMClientPath=$sCSOMPath +  "\Microsoft.SharePoint.Client.dll" 
        #$sCSOMUploadPath= $sCSOMPath +" \Microsoft.SharePoint.Client.Publishing.dll"
            #Load SharePoint Online CSOM Assemblies 
                Add-Type -Path $sCSOMClientPath     | out-null
                Add-Type -Path $sCSOMRuntimePath    | out-null
            catch {
                Add-LogEntry $logFilePath  $requestNumber  $env:hostname 'error' "failed loading assemblies"
                return Get-JsonStatus 1 "required dlls for SharePoint on $env:computername not found."


$item["Manager"] might be the value you try to put into a list item.
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


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 D: ?