Skip to content

Commit c0ea760

Browse files
Managing tenant properties doc improvements (SharePoint#4428)
* SharePoint#4409 adding PnP PowerShell to documentation documenting behavior on no-script sites * SharePoint#4409 correcting spelling
1 parent a7d19b3 commit c0ea760

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

docs/spfx/tenant-properties.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Tenant properties allow tenant administrators to add properties in the app catal
1212

1313
Alternatively, the [Office 365 CLI](https://pnp.github.io/office365-cli?utm_source=msft_docs&utm_medium=page&utm_campaign=Use+SharePoint+Online+tenant+properties) can be used to manage the tenant properties. The Office 365 CLI is a cross-platform command line interface that can be used on any platform, including Windows, MacOS and Linux.
1414

15-
## Manage tenant properties
15+
Yet another alternative for managing tenant properties is [PnP PowerShell](https://aka.ms/sppnp-powershell). The advantage of PnP PowerShell is that it does not require tenant administrator privileges to set those properties. Any member of the Owners group of an app catalog site can do this. This applies to the tenant app catalog site as well as [site collection app catalogs](../general-development/site-collection-app-catalog.md).
16+
17+
## Use Microsoft SharePoint Online Management Shell commands to get, set and remove tenant properties
1618

1719
Using the [Microsoft SharePoint Online Management Shell](https://www.microsoft.com/download/details.aspx?id=35588), tenant administrators can use PowerShell to add and remove tenant properties.
1820

@@ -38,7 +40,7 @@ Before running the following script, connect to your SharePoint Online tenant us
3840

3941
- **Syntax** Remove-SPOStorageEntity [-Site] <AppCatalogSiteURL> [-Key] <String>
4042

41-
## Office 365 CLI commands to get, set, remove and list tenant properties cross-platform
43+
## Use Office 365 CLI commands to get, set, remove and list tenant properties cross-platform
4244

4345
Using the [Office 365 CLI](https://pnp.github.io/office365-cli?utm_source=msft_docs&utm_medium=page&utm_campaign=Use+SharePoint+Online+tenant+properties), tenant administrators can use shell commands to manage tenant properties.
4446

@@ -82,6 +84,70 @@ To set or remove a tenant property, you have to first connect to a tenant admin
8284

8385
Tenant properties are stored in the app catalog site associated with that tenant. To set or remove a property, you have to specify the absolute URL of the app catalog site. If you specify the URL of a site different than the app catalog, you will get an access denied error.
8486

87+
88+
## Use PnP PowerShell cmdlets to get, set, remove and list tenant properties
89+
90+
Using [PnP PowerShell](https://aka.ms/sppnp-powershell), site owners and site collection administrators can use PowerShell cmdlets to manage tenant properties.
91+
92+
Before using the cmdlets, connect to a SharePoint Online site, using the `Connect-PnPOnline` cmdlet.
93+
94+
### Get details for the specified tenant property
95+
96+
The [Get-PnPStorageEntity](/powershell/module/sharepoint-pnp/get-pnpstorageentity) cmdlet can be used to get details for a SharePoint Online tenant property
97+
98+
Get property from tenant app catalog:
99+
```powershell
100+
Get-PnPStorageEntity -Key <key>
101+
```
102+
103+
Get property from a site collection app catalog:
104+
```powershell
105+
Get-PnPStorageEntity -Key <key> -Scope Site
106+
```
107+
108+
### List tenant properties stored on a SharePoint Online app catalog
109+
110+
The [Get-PnPStorageEntity](/powershell/module/sharepoint-pnp/get-pnpstorageentity) cmdlet can be used to list all the tenant properties.
111+
112+
List properties of tenant app catalog:
113+
```powershell
114+
Get-PnPStorageEntity
115+
```
116+
List properties of site collection app catalog:
117+
```powershell
118+
Get-PnPStorageEntity -Scope Site
119+
```
120+
121+
### Set tenant property on a SharePoint Online app catalog
122+
123+
The [Set-PnPStorageEntity](/powershell/module/sharepoint-pnp/set-pnpstorageentity) cmdlet can be used to set a tenant property.
124+
125+
Set property for tenant app catalog:
126+
```powershell
127+
Set-PnPStorageEntity -Key <key> -Value <value>
128+
```
129+
Set property for site collection app catalog:
130+
```powershell
131+
Set-PnPStorageEntity -Key <key> -Value <value> -Scope Site
132+
```
133+
134+
### Remove tenant property stored on a SharePoint Online app catalog
135+
136+
The [Remove-PnPStorageEntity](/powershell/module/sharepoint-pnp/remove-pnpstorageentity) cmdlet can be used to remove a tenant property.
137+
138+
Remove property from tenant app catalog:
139+
```powershell
140+
Remove-PnPStorageEntity -Key <key>
141+
```
142+
Remove property from site collection app catalog:
143+
```powershell
144+
Remove-PnPStorageEntity -Key <key> -Scope Site
145+
```
146+
147+
### Remarks when using the PnP PowerShell cmdlets
148+
149+
You can connect to any site using the `Connect-PnPOnline` cmdlet, eg. Connect-PnPOnline https://contoso.sharepoint.com/sites/marketing. When you omit the `-Scope` parameter or set it to `Tenant` (which is the default value) all cmdlets apply to the tenant app catalog regardless of the site you connected to. If you set the `-Scope` parameter to `Site` all cmdlets will apply to the site collection app catalog of the site you connected to.
150+
85151
## Read tenant properties
86152

87153
Developers can read tenant properties by using the SharePoint REST APIs and use them in SharePoint Framework components such as web parts and extensions.
@@ -118,6 +184,16 @@ Content-Type: application/json
118184
}
119185
```
120186

187+
## Custom script and site collection app catalogs
188+
189+
It is only allowed to set tenant properties on site collection app catalogs in sites that have custom scripts enabled. When you try to set a tenant property in a "no-script site" the following error will be shown:
190+
191+
> Access denied. You do not have permission to perform this action or access this resource.
192+
193+
You can learn more about custom scripts here: [Allow or prevent custom script](/sharepoint/allow-or-prevent-custom-script).
194+
195+
Note that above error message will also be shown if you are not owner or site collection administrator of the site.
196+
121197
## See also
122198

123199
- [Overview of the SharePoint Framework](sharepoint-framework-overview.md)

0 commit comments

Comments
 (0)