Skip to content

/errors/sharepoint-online/cannot-convert-value-to-type-spositepipebind

Get-SPOSite: Cannot bind parameter 'Identity'. Cannot convert value to type "SpoSitePipeBind"

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
SharePoint Online PowerShell
exit code
1
versions
Microsoft.Online.SharePoint.PowerShell 16.0.27709.12000, Windows PowerShell 5.1
os
windows

Get-SPOSite : Cannot bind parameter 'Identity'. Cannot convert value "HR Team" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind". Error: "SpoSitePipeBind Url" means -Identity did not get a full site URL. SharePoint Online Management Shell cmdlets (Get-SPOSite, Set-SPOSite, Remove-SPOSite, Set-SPOUser, ...) identify a site only by its absolute URL, including https://:

powershell
Get-SPOSite -Identity https://contoso.sharepoint.com/sites/hr
Set-SPOSite -Identity https://contoso.sharepoint.com/sites/hr -SharingCapability Disabled

The conversion happens while PowerShell binds parameters, before the cmdlet checks the connection, so the error appears whether or not Connect-SPOService has run.

Reproduce it

Module Microsoft.Online.SharePoint.PowerShell 16.0.27709.12000 in Windows PowerShell 5.1, with a title, a relative path, a URL without scheme and a full URL:

powershell
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
foreach ($v in 'HR Team', '/sites/hr', 'contoso.sharepoint.com/sites/hr', 'https://contoso.sharepoint.com/sites/hr') {
  "--- $v"
  try {
    Get-SPOSite -Identity $v -ErrorAction Stop
  } catch {
    $_.Exception.Message
  }
}
"--- CSV row object"
$row = [pscustomobject]@{ Url = "https://contoso.sharepoint.com/sites/hr" }
try { Get-SPOSite -Identity $row -ErrorAction Stop } catch { $_.Exception.Message }

Output

--- HR Team
Cannot bind parameter 'Identity'. Cannot convert value "HR Team" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind". Error: "SpoSitePipeBind Url"
--- /sites/hr
Cannot bind parameter 'Identity'. Cannot convert value "/sites/hr" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind". Error: "SpoSitePipeBind Url"
--- contoso.sharepoint.com/sites/hr
Cannot bind parameter 'Identity'. Cannot convert value "contoso.sharepoint.com/sites/hr" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind". Error: "SpoSitePipeBind Url"
--- https://contoso.sharepoint.com/sites/hr
No connection available. Use Connect-SPOService before running this CmdLet.
--- CSV row object
Cannot bind parameter 'Identity'. Cannot convert the "@{Url=https://contoso.sharepoint.com/sites/hr}" value of type "System.Management.Automation.PSCustomObject" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind".

The first three values fail with the conversion error. The full URL is accepted, and without a session the cmdlet then stops with No connection available. Use Connect-SPOService, which shows that the binding step passed.

Find the URL of a site by its title

powershell
Connect-SPOService -Url https://contoso-admin.sharepoint.com
Get-SPOSite -Limit All | Where-Object Title -eq 'HR Team' | Select-Object Title, Url

For OneDrive accounts, list personal sites with Get-SPOSite -IncludePersonalSite $true -Limit All -Filter "Url -like '-my.sharepoint.com/personal/'"; their URLs are the values -Identity expects.

In scripts that read a CSV

powershell
Import-Csv .\sites.csv | ForEach-Object {
  Set-SPOSite -Identity $_.Url -SharingCapability ExistingExternalUserSharingOnly
}

Passing $_ instead of $_.Url sends the whole row, and the message names the object type instead: Cannot convert the "@{Url=https://contoso.sharepoint.com/sites/hr}" value of type "System.Management.Automation.PSCustomObject" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind" (last case of the block above). Other parameters with a fixed list of values fail in a similar way when the value is not allowed; see SharingCapability cannot convert value.

Sources