2

Do anyone have online PowerShell to get list of all site mailboxes along with site URL's. Soon Microsoft is going to decommission site mailboxes so we need to know list of sites that are using site mailboxes.

4

I have the same requirement at my company and created something that may work for you. If you are the SharePoint Administrator (and have Admin rights across the Tenant) this will work. If you just want to look at one/several site collections that you have Admin access, you can doctor this to look directly at the Site Collection and it's subsites.

This method looks for the Site Mailbox feature being activated on the site.

# List all Site Collections in Tenant and Look for Site Mailbox Feature


# Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll"
Add-Type -Path "C:\Program Files\SharePoint Client Components\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll"

#Request login credetials
$encrypted = "YourPW"
$User = "YourEmail@yourdomain.com"
$Pwd = ConvertTo-SecureString $encrypted -AsPlainText -Force

# Tenant Admin Url
$rootWeb = "https://YourCompany-admin.sharepoint.com/"

# Bind to Admin Url
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($rootWeb)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Pwd)
$clientContext.Credentials = $Creds

$spoTenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($clientContext)
$spoTenantSiteCollections = $spoTenant.GetSiteProperties(0,$true)
$clientContext.Load($spoTenantSiteCollections)
$clientContext.ExecuteQuery()

if (!$clientContext.sesrverobjectisnull.value) {
        Write-Host "Connected to SPO site: $rootweb" -ForegroundColor Green
        Write-Host "-----------------------------------------------------------------"
        Write-Host ""
    }

# Look through all site Collections in Tenant
foreach($spoSiteCollection in $spoTenantSiteCollections) {

        $newWeb = $spoSiteCollection.Url

        # Get the Url of the current Site Collection
        Write-Host $spoSiteCollection.Url -NoNewline

        # Connect to site collection
        $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($newWeb)
        $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Pwd)
        $ctx.Credentials = $Creds

        if (!$ctx.sesrverobjectisnull.value) { Write-Host " -Connected- " -ForegroundColor Green -NoNewline }        

        # Get all Subsites for Current Site Collection
        $newWeb = $ctx.Web
        $childWebs = $newWeb.Webs
        $ctx.Load($newWeb)
        $ctx.Load($childWebs)
        $ctx.ExecuteQuery()

        Write-Host $childWebs.Count
        if ($childWebs.Count -gt 0) {
            foreach ($childWeb in $childWebs){
                $features = $childWeb.Features
                $ctx.Load($features)
                $ctx.ExecuteQuery()
                $siteMailbox = $features | where { $_.DefinitionId -eq "502a2d54-6102-4757-aaa0-a90586106368" }
                if ($siteMailbox) { Write-Host "**Site Mailbox: " $childweb.Url -ForegroundColor Yellow}
            }
        }
    }



$clientContext.Dispose()

To Just Look at a specific site collection, you could try this:

#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"


#Request login credetials
$encrypted = "YourPW"
$User = "YourEmail@yourdomain.com"
$Pwd = ConvertTo-SecureString $encrypted -AsPlainText -Force

#SPO Site URL
$rootWeb = "https://YourCompany.sharepoint.com/sites/YourSiteCollection"

#Bind to site collection
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($rootWeb)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Pwd)
$clientContext.Credentials = $Creds

if (!$clientContext.sesrverobjectisnull.value)
    {
        Write-Host "Connected to SPO site: $rootweb" -ForegroundColor Green
    }

$rootWeb = $clientContext.Web
$childWebs = $rootWeb.Webs
$clientContext.Load($rootWeb)
$clientContext.Load($childWebs)
$clientContext.ExecuteQuery()


function processWeb($web) {

    $clientContext.Load($web)
    $clientContext.ExecuteQuery()
    Write-Host $web.Title

    $features = $web.Features
    $clientContext.Load($features)
    $clientContext.ExecuteQuery()
    $siteMailbox = $features | where { $_.DefinitionId -eq "502a2d54-6102-4757-aaa0-a90586106368" }
    if ($siteMailbox) { Write-Host "**Site Mailbox: " $childweb.Url -ForegroundColor Yellow}
}

foreach ($childWeb in $childWebs)
    {
            processWeb($childWeb)
    } 


$clientContext.Dispose()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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