1

So I am new SharePoint online administrator and working at a small company. I got a task to move my company into SharePoint which before were used minimaly without much of administration.

Today I found out that there is at least a few sites that is in root directory. As most sites are https://companyname.sharepoint.com/sites/SiteName, these are in https://companyname.sharepoint.com/SiteName. I currently trying to get a list of these sites to prepare a plan on how to deal with them, I tried using Get-SPOSite in sharepoint, but showed only sites that I can see in admin panel as well.

Waqas Sarwar MVP
  • 57,008
  • 17
  • 43
  • 79
Ignas
  • 25
  • 2
  • refer this link, it has powershell approach, https://sharepoint.stackexchange.com/questions/101176/powershell-to-list-all-sites-and-subsites-in-sharepoint-online – Karthik Jaganathan Dec 11 '19 at 13:10
  • thanks for your reply, I have tried this approach already, but it returns only sites that are in sharepoint.com/sites/ location while sites ub sharepoint.com/ doesn't show up. – Ignas Dec 11 '19 at 13:47

1 Answers1

0

You can get this using the PNPPowerShel

  #Get Credentials to connect
$Cred = Get-Credential

Connect-PnPOnline -Url https://teanat-admin.sharepoint.com -Credentials $Cred

$allsites = Get-PnPTenantSite

foreach($site in $allsites) { Try { #Connect to PNP Online Connect-PnPOnline -Url $Site.url -Credentials $Cred

    #Get subsites in SharePoint Online using PnP PowerShell
    $WebsCollection = Get-PnPSubWebs -Recurse

    ForEach($Web in $WebsCollection)
    {
        Write-host "Site Collection URL =" $site.Url " has this subwebs =" $Web.Url
    }
    }
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
    }

}

Disconnect-PnPOnline

Read more: https://www.sharepointdiary.com/2016/02/powershell-to-get-all-subsites-in-sitecollection-sharepoint-online.html#ixzz67o162L6J

Waqas Sarwar MVP
  • 57,008
  • 17
  • 43
  • 79