Forum Discussion
Lokeswar_Reddy
Apr 26, 2022Copper Contributor
Unable to connect sharepoint online site collection using powershell
I have to upload the CSV file data to the SharePoint list using Powershell, here the connection is established up to the admin site. but it is not accessing the Sharepoint site collection, showing an...
Kevin_Morgan
Apr 26, 2022Iron Contributor
This is expected error since you need to pass the Admin site URL (Tenant site url) for Connect-SPOService.
You can check this post : https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/connect-sposervice
Connect-SPOService -url https://TenantName-admin.sharepoint.com
As you know, the Connect-SPOService cmdlet is belong to SPO Management module. For List items update, you have to either use CSOM based script or PnP PowerShell commands.
$SiteUrl = "https://crescent.sharepoint.com/sites/marketing"
$ListName = "CustomerContacts"
$CSVPath = "C:\temp\CustomerContacts.csv"
#Get CSV file content
$CSVData = Import-CsV -Path $CSVPath
#Connect to site
Connect-PnPOnline $SiteUrl -Interactive
#Iterate through each Row in the CSV and import as list item SPO List
ForEach ($Row in $CSVData)
{
#Add List Items
Add-PnPListItem -List $ListName -Values @{
"CustomerName" = $($Row.CustomerName);
"Email" = $($Row.Email);
"Mobile" = $($Row.Mobile);
};
}
Lokeswar_Reddy
Apr 26, 2022Copper Contributor
Thanks for your reply,
Actually, I do not see any error while connecting to the admin site, only here this issue is connecting to the Sharepoint site collection.
please let me know about this issue.
Actually, I do not see any error while connecting to the admin site, only here this issue is connecting to the Sharepoint site collection.
please let me know about this issue.