Skip to content
61 changes: 61 additions & 0 deletions documentation/Get-PnPTenantInternalSetting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
Module Name: PnP.PowerShell
title: Get-PnPTenantInternalSetting
schema: 2.0.0
applicable: SharePoint Online
external help file: PnP.PowerShell.dll-Help.xml
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPTenantInternalSetting.html
---

# Get-PnPTenantInternalSetting

## SYNOPSIS

**Required Permissions**

* SharePoint: Access to the SharePoint Tenant Administration site

Returns additional organizational level site collection properties available from endpoint `/_api/SPOInternalUseOnly.TenantAdminSettings`. This is an undocumented endpoint. Usage of this cmdlet might be subject to change if Microsoft changes the response.

## SYNTAX

```powershell
Get-PnPTenantInternalSetting [-Connection <PnPConnection>]
```

## DESCRIPTION
Returns organizational level site collection properties such as `SitePagesEnabled`, `DisableSelfServiceSiteCreation`, `EnableAutoNewsDigest`,
`CustomFormUrl`, `AutoQuotaEnabled`, `DisableGroupify`, `IncludeAtAGlanceInShareEmails`, `MailFromAddress`, `MobileNotificationIsEnabledForSharepoint`, `NewSiteManagedPath`, `NewSubsiteInModernOffForAll`, `NewSubsiteInModernOffForModernTemplates`, `NewTeamSiteManagedPath`, `ParentSiteUrl`, `PolicyOption`, `RequireSecondaryContact`, `ShowSelfServiceSiteCreation`, `SiteCreationNewUX`, `SmtpServer`, `SPListModernUXOff`, `TenantDefaultTimeZoneId` and `AvailableManagedPathsForSiteCreation`.

Currently, there are no parameters for this cmdlet.

You must have the SharePoint Online admin or Global admin role to run the cmdlet.

## EXAMPLES

### EXAMPLE 1
```powershell
Get-PnPTenantInternalSetting
```

This example returns internal tenant settings.

## PARAMETERS

### -Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

```yaml
Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
20 changes: 20 additions & 0 deletions src/Commands/Admin/GetTenantInternalSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.SharePoint.Client;

using PnP.PowerShell.Commands.Base;
using System.Management.Automation;
using PnP.PowerShell.Commands.Model;

namespace PnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsCommon.Get, "PnPTenantInternalSetting")]
public class GetTenantInternalSetting : PnPAdminCmdlet
{
protected override void ExecuteCmdlet()
{
AdminContext.Load(Tenant);

AdminContext.ExecuteQueryRetry();
WriteObject(new SPOTenantInternalSetting(Tenant, AdminContext));
}
}
}
124 changes: 124 additions & 0 deletions src/Commands/Model/SPOTenantInternalSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using System.Text.Json;

namespace PnP.PowerShell.Commands.Model
{
public class SPOTenantInternalSetting
{
#region Internal Settings properties
public bool SitePagesEnabled { private set; get; }
public bool DisableSelfServiceSiteCreation { private set; get; }
public bool EnableAutoNewsDigest { private set;get; }
public string CustomFormUrl { private set; get; }
public bool AutoQuotaEnabled { get; private set; }
public bool DisableGroupify { get; private set; }
public bool IncludeAtAGlanceInShareEmails { get; private set; }
public string MailFromAddress { get; private set; }
public bool MobileNotificationIsEnabledForSharepoint { get; private set; }
public string NewSiteManagedPath { get; private set; }
public bool NewSubsiteInModernOffForAll { get; private set; }
public bool NewSubsiteInModernOffForModernTemplates { get; private set; }
public string NewTeamSiteManagedPath { get; private set; }
public string ParentSiteUrl { get; private set; }
public string PolicyOption { get; private set; }
public bool RequireSecondaryContact { get; private set; }
public bool ShowSelfServiceSiteCreation { get; private set; }
public int SiteCreationDefaultStorageQuota { get; private set; }
public bool SiteCreationNewUX { get; private set; }
public string SmtpServer { get; private set; }
public bool SPListModernUXOff { get; private set; }
public int TenantDefaultTimeZoneId { get; private set; }
public string[] AvailableManagedPathsForSiteCreation { get; private set; }

#endregion

public SPOTenantInternalSetting(Tenant tenant, ClientContext clientContext)
{
try
{
this.initSPOTenantInternalSetting(clientContext);
}
catch
{
}
}
private void initSPOTenantInternalSetting(ClientContext clientContext)
{
var httpClient = PnP.Framework.Http.PnPHttpClient.Instance.GetHttpClient(clientContext);
var internalSettingsData = Utilities.REST.RestHelper.GetAsync<TenantInternalSetting>(httpClient, $"{clientContext.Url}_api/SPOInternalUseOnly.TenantAdminSettings", clientContext.GetAccessToken(), false).GetAwaiter().GetResult();

SitePagesEnabled = internalSettingsData.SitePagesEnabled.Value;
DisableSelfServiceSiteCreation = internalSettingsData.DisableSelfServiceSiteCreation.Value;
EnableAutoNewsDigest = internalSettingsData.EnableAutoNewsDigest.Value;
CustomFormUrl = internalSettingsData.CustomFormUrl.Value;
AutoQuotaEnabled = internalSettingsData.AutoQuotaEnabled.Value;
DisableGroupify = internalSettingsData.DisableGroupify.Value;
IncludeAtAGlanceInShareEmails = internalSettingsData.IncludeAtAGlanceInShareEmails.Value;
MailFromAddress = internalSettingsData.MailFromAddress.Value;
MobileNotificationIsEnabledForSharepoint = internalSettingsData.MobileNotificationIsEnabledForSharepoint.Value;
NewSiteManagedPath = internalSettingsData.NewSiteManagedPath.Value;
NewSubsiteInModernOffForAll = internalSettingsData.NewSubsiteInModernOffForAll.Value;
NewSubsiteInModernOffForModernTemplates = internalSettingsData.NewSubsiteInModernOffForModernTemplates.Value;
NewTeamSiteManagedPath = internalSettingsData.NewTeamSiteManagedPath.Value;
ParentSiteUrl = internalSettingsData.ParentSiteUrl.Value;
PolicyOption = internalSettingsData.PolicyOption.Value;
RequireSecondaryContact = internalSettingsData.RequireSecondaryContact.Value;
ShowSelfServiceSiteCreation = internalSettingsData.ShowSelfServiceSiteCreation.Value;
SiteCreationNewUX = internalSettingsData.SiteCreationNewUX.Value;
SmtpServer = internalSettingsData.SmtpServer.Value;
SPListModernUXOff = internalSettingsData.SPListModernUXOff.Value;
TenantDefaultTimeZoneId = internalSettingsData.TenantDefaultTimeZoneId.Value;
AvailableManagedPathsForSiteCreation = internalSettingsData.AvailableManagedPathsForSiteCreation;
}
private class TenantInternalSetting
{
#region Properties
public SettingsBoolProperty AutoQuotaEnabled { get; set; }
public string[] AvailableManagedPathsForSiteCreation { get; set; }
public SettingsBoolProperty IncludeAtAGlanceInShareEmails { get; set; }
public SettingsStringProperty MailFromAddress { get; set; }
public SettingsBoolProperty MobileNotificationIsEnabledForSharepoint { get; set; }
public SettingsStringProperty NewSiteManagedPath { get; set; }
public SettingsStringProperty ParentSiteUrl { get; set; }
public SettingsStringProperty PolicyOption { get; set; }
public SettingsBoolProperty RequireSecondaryContact { get; set; }
public SettingsBoolProperty ShowSelfServiceSiteCreation { get; set; }
public SettingsBoolProperty SiteCreationNewUX { get; set; }
public SettingsStringProperty SmtpServer { get; set; }
public SettingsBoolProperty SPListModernUXOff { get; set; }
public SettingsIntProperty TenantDefaultTimeZoneId { get; set; }
public SettingsBoolProperty SitePagesEnabled { get; set; }
public SettingsBoolProperty DisableGroupify { get; set; }
public SettingsStringProperty CustomFormUrl { get; set; }
public SettingsBoolProperty EnableAutoNewsDigest { get; set; }
public SettingsBoolProperty DisableSelfServiceSiteCreation { get; set; }
public SettingsBoolProperty NewSubsiteInModernOffForAll { get; set; }
public SettingsBoolProperty NewSubsiteInModernOffForModernTemplates { get; set; }
public SettingsStringProperty NewTeamSiteManagedPath { get; set; }

#endregion

#region Helper Types
public class SettingsBoolProperty
{
public bool IsReadOnly { get; set; }
public bool Value { get; set; }
}
public class SettingsIntProperty
{
public bool IsReadOnly { get; set; }
public int Value { get; set; }
}
public class SettingsStringProperty
{
public bool IsReadOnly { get; set; }
public string Value { get; set; }
}

#endregion
}

}

}