Forum Discussion
Unable to connect sharepoint online site collection using powershell
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);
};
}
The point is: You can't connect the individual site collection using this command (Connect-SPOService ). The command is designed to connect only with admin site. Once you connected the Admin site, you can use the following command to get specific site details.
Get-SPOSite -Identity https://contoso.sharepoint.com
And you can use the commands listed in the below post to manage SPO sites.
https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/?view=sharepoint-ps
You can use these commands only to manage SPO sites and I believe, you can't manage specific list or list items using these commands. So, you have to either use PnP PowerShell or CSOM based PowerShell.