Tag Archives: Office 365

Long-running PowerShell Office 365 reports


PowerShell is our best friend when it comes to ad-hoc and/or scheduled reports in Microsoft 365. PnP team is doing great job providing more and more functionality with PnP PowerShell module for Office 365 SharePoint and Teams.

Small and medium business organizations are mostly good, but for large companies it might be a problem due to just huge amount of data stored in SharePoint. PowerShell reports on all users or all sites might run days… which is probably OK if you run this report once, but totally not acceptable if you need this report e.g. daily/weekly or on-demand.

How can we make heavy PowerShell scripts run faster?

Of course, you start with logic (algorithm) and leveraging full PowerShell functionality.



What if you did everything, but it still takes too long?
– Automation account runbook (+workflow)
– PowerShell 7 parallelism
– Azure VM in the region closest to your Tenant


PnP PowerShell

Microsoft Office 365 tenant exact location

Microsoft says: “Customers should view tenant specific data location information in your Microsoft 365 Admin Center in Settings | Org settings | Organization Profile | Data location.”
And it might look like:

That’s accurate to the geography (e.g. US, UE, AP), but not to the region (for instance – “Central US”, “UK West” or “Australia Southeast”).
In other words, If you know your data are in the US, you never know where exactly – East/West/Central or South US.
Meantime when you create an Azure resource (e.g. Virtual Machine) – you can select specific region.

How do I know – where is my Microsoft 365 tenant actually located?

Can we just ping the tenant, analyze result and find Office 365 tenant region?
Luckily, SharePoint tenant is pinging with just
PS>ping tenantName.SharePoint.com
I have tested 5 regions and 4 different tenants:

ping from/to (ms)tenant 1 (US)tenant 2 (EU)tenant 3 (US)tenant 4 (US)
North Europe731796101
East US1833931
Central US221142323
West US631463633
South Central US3111211

So for me it’s clear how to find Microsoft 365 tenant region exact locations.
My tenants ##3 and 4 are in South Central US, tenant # 1 resides in East US.

Why do I need this? Imagine you are running heavy reports against your tenant.
So probably you want your code running as close as possible to your tenant.
(please check also “Long-running PowerShell reports optimization in Office 365”)

Where your Microsoft 365 customer data is stored

Allow commenting on modern pages (SharePoint Online)

Microsoft: “You can also select to allow or prevent commenting on modern pages. If you allow commenting, it can be turned on or off at the page level

By default both
– Allow users to create new modern pages
– Allow commenting on modern pages
are turned on (enabled)

Tenant or SharePoint admin can find settings under
SharePoint Admin Center -> Settings -> Pages

When you are creating a modern site page – there is an option “Comments” turned On by default:

And page with comments looks like:

Comments on site pages (aka modern pages) can be enabled or disabled at each of the levels:
– Tenant level
– Site (aka site collection) level
– Web (aka subsite ) level
– Page level
Here is how it is done:

LevelHow it’s doneWho can do it
TenantGUI ( SharePoint Administration)
or PowerShell
Global Administrator or
SharePoint Administrator
Site (Site Collection)PowerShellGlobal Administrator or
SharePoint Administrator
Web (Subsite)PowerShellSite Collection Administrator or Owner
(Full Control rights to web)
PageGUI (Page Editing screen)Site Member
(Edit right to page)

If commenting on modern pages disabled at higher level – lower level settings do not work. E.g. If you disable “Allow commenting on modern pages” at tenant level (it takes minutes) – the functionality will gone from all modern pages of all sites.

When you switch page comments Off – all existing comments will be hidden (but not deleted).
If you later turn comments On – comments will reappear, including Likes.

If “Allow commenting on modern pages” disabled at tenant or web level – you will not see “Comments On/Off” switch while editing page.
If “Allow commenting on modern pages” disabled at site collection level – you will see “Comments On/Off” switch while editing page, but you will not be able to turn it ON.


When you disable “Allow commenting on modern pages” at tenant level –
PowerShell Object (site/web) property “CommentsOnSitePagesDisabled” will not be changed for any site/web.
You can still with PowerShell set it to True/False:
“Set-PnPWeb -CommentsOnSitePagesDisabled:$false”
but it does not take any effect.

If you enable “Allow commenting on modern pages” at tenant level (it takes ~10 minutes) – the functionality will return to all modern pages and
all webs and sites properties “CommentsOnSitePagesDisabled” will ???.
You can change it with PowerShell:
“Set-PnPWeb -CommentsOnSitePagesDisabled:$false”.

# having Site Collection Admin Permissions:
# disable Comments On Site Pages for a subsite:
$webName = "SubSite_02"
Set-PnPWeb -Web $webName -CommentsOnSitePagesDisabled:$true 
# enable Comments On Site Pages for a subsite 
# (only if comments enabled at tenant level):
Set-PnPWeb -Web $webName -CommentsOnSitePagesDisabled:$false

# having global admin or SharePoint admin permissions:
# site collection:
Set-PnPTenantSite -Url $siteUrl -CommentsOnSitePagesDisabled:$true
# tenant-level Comments:
Set-PnPTenant -CommentsOnSitePagesDisabled:$true # disable
Set-PnPTenant -CommentsOnSitePagesDisabled:$false # enable comments

# does not work:
Set-PnPSite -CommentsOnSitePagesDisabled:$true

– Microsoft “Allow users to create and comment modern pages

See also:
Allow users to create modern pages

We did not discuss “Wiki Pages” or “Web part Pages”, we discussed only “Modern Pages” (aka Site Pages).
I have tested it all personally using Communication sites.
MS-Team (group-based) and standalone SharePoint (no-group) sites – TBP.