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.

2
  • refer this link, it has powershell approach, sharepoint.stackexchange.com/questions/101176/… Commented Dec 11, 2019 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
    Commented Dec 11, 2019 at 13:47

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.