Hope you have a great day.
The error "Parameter set cannot be resolved using the specified named parameters" typically occurs when there is a conflict or an incorrect combination of parameters in your PowerShell command.
We ran a test where the above error occurs after specifying -Tenant
. Since -Tenant
is not a required parameter, we can omit it. Refer to the documentation for the Connect-PnPOnline command.
I made some changes based on the PowerShell command you provided to extract the owner of the SharePoint site. Please try to see if the PowerShell command I provided works.
#Parameters
$AdminSiteURL = "https://contoso-admin.sharepoint.com"
$CSVPath = "C:\SiteOwners.csv"
$ClientId = "xxxxxxx"
$ClientSecret = "xxxxxxxx"
#Connect to Admin Center Site
Connect-PnPOnline -Url $AdminSiteURL -ClientId $ClientId -ClientSecret $ClientSecret
#Get All Site collections
$SiteCollections = Get-PnPTenantSite
$SiteOwners = @()
#Loop through each site collection
ForEach($Site in $SiteCollections)
{
Write-host -F Green "Site Owner(s) of the site: " $Site.Url
Connect-PnPOnline -Url $Site.Url -ClientId $ClientId -ClientSecret $ClientSecre
If($Site.Template -like 'GROUP*')
{
#Get Group Owners
$Owners = (Get-PnPMicrosoft365GroupOwners -Identity ($Site.GroupId) | Select -ExpandProperty Email) -join "; "
}
Else
{
#Get Site Owner
$Owners = $Site.Owner
}
#Collect Data
$SiteOwners += New-Object PSObject -Property @{
'Site Title' = $_.Title
'URL' = $_.Url
'Owner(s)' = $Owners
}
}
#Get Site Owners
$SiteOwners
#Export Site Owners report to CSV
$SiteOwners | Export-Csv -path $CSVPath -NoTypeInformation
Reference: SharePoint Online: Get the Site Owner using PowerShell
Non-official, just for reference.
If you have any questions, please do not hesitate to contact me.
Moreover, if the issue can be fixed successfully, please click "Accept Answer" so that we can better archive the case and the other community members who are suffering the same issue can benefit from it.
Your kind contribution is much appreciated.