Forum Discussion
Import items from a CSV file to a Sharepoint Online list
If you run a import-module Microsoft.Online.Sharepoint.PowerShell -verbose, do you see VERBOSE: Importing cmdlet 'Set-SPOUser'. ?
And if I run import-module Microsoft.Online.Sharepoint.PowerShell -verbose I have this : https://zupimages.net/up/22/14/2o3h.png
Harm_Veenstra
- 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> - Micca0815Apr 05, 2022Iron Contributor$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
}
#disconnect - Micca0815Apr 05, 2022Iron Contributor
as you make use of CSOM and SharePoint Online Management shell, I`d suggest to download the latest CSOM libraries from here:
https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOMand 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 try{ 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." } }
- 444456464Apr 05, 2022Copper ContributorYes^^
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 - Apr 05, 2022Could you select the text and translate it to English?
- 444456464Apr 05, 2022Copper ContributorI did everything that was stated on the forum. So now instead of my old mistakes, I have new ones :
https://zupimages.net/up/22/14/s1ul.png
Harm_Veenstra - Apr 05, 2022There was another topic about this in the past https://techcommunity.microsoft.com/t5/office-365/can-t-import-sharepoint-online-powershell-module/m-p/359581
- 444456464Apr 05, 2022Copper ContributorI have try this but I have the same problem ;--;
- Apr 05, 2022Could you try this? Cleanup of any previous installations and reinstall
- 444456464Apr 05, 2022Copper ContributorOkey ! I have try it but I have this errors : https://zupimages.net/up/22/14/tm68.png
- Apr 05, 2022Could 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?