Skip to content

Get-PnPHubSite doesn't return NULL then the specified URL or Id points to a site that is not a hub site #5032

@kasperbolarsen

Description

@kasperbolarsen

Actual behavior

Get-PnPHubSite currently returns a not-null respons when calling using a valid URL to a site that is not a hub site. I would expect a null value

Steps to reproduce behavior

part of an Azure Function:
$SPOAdminUrl = "the URL of the SP admin site"
$siteUrl = "contoso.sharepoint.com/sites/nothubsite"
$adminConn = Connect-PnPOnline -Url $SPOAdminUrl -Interactive -ClientId $PnPClientId -ReturnConnection
$hubSite = Get-PnPHubSite -Identity $siteUrl -Connection $adminConn -ErrorAction Stop
if($hubSite) #this fails as $hubSite is not null
{
$body += "The site $siteUrl is already registered as a hub site"
$StatusCode = [HttpStatusCode]::AlreadyReported
}

What is the version of the Cmdlet module you are running?

3.1.0

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions