-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1678 from swapnil1993/dev
Added pnp cmdlet for getting compatible content types from ct hub
- Loading branch information
Showing
6 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
online version: https://pnp.github.io/powershell/cmdlets/Add-PnPContentTypesFromContentTypeHub.html | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
title: Get-PnPCompatibleHubContentTypes | ||
--- | ||
|
||
# Get-PnPCompatibleHubContentTypes | ||
|
||
## SYNOPSIS | ||
|
||
**Required Permissions** | ||
|
||
* ViewPages permission on the current web. | ||
|
||
Returns the list of content types present in content type hub site that can be added to the root web or a list on a target site. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPCompatibleHubContentTypes -WebUrl <String> [-ListUrl <String>] [-Connection <PnPConnection>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPCompatibleHubContentTypes -WebUrl 'https://contoso.sharepoint.com/web1' | ||
``` | ||
|
||
This will return the list of content types present in content type hub site that can be added to the root web of the site to which the provided web belongs. | ||
|
||
### EXAMPLE 2 | ||
```powershell | ||
Get-PnPCompatibleHubContentTypes -WebUrl 'https://contoso.sharepoint.com/web1' -ListUrl 'https://contoso.sharepoint.com/web1/Shared Documents' | ||
``` | ||
|
||
This will return the list of content types present in content type hub site that can be added to the provided list. | ||
|
||
## PARAMETERS | ||
|
||
### -WebUrl | ||
The full URL of the web for which compatible content types need to be fetched. In case of a list this should be the url of the web which contains the given list. I.e. 'https://contoso.sharepoint.com/web1' | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -ListUrl | ||
The full URL to the list for which compatible content types need to be fetched, i.e. 'https://contoso.sharepoint.com/web1/Shared Documents' | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Management.Automation; | ||
using Microsoft.SharePoint.Client; | ||
|
||
namespace PnP.PowerShell.Commands.ContentTypes | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPCompatibleHubContentTypes")] | ||
public class GetCompatibleHubContentTypes : PnPWebCmdlet | ||
{ | ||
[Parameter(Mandatory = true)] | ||
[ValidateNotNullOrEmpty] | ||
public string WebUrl; | ||
|
||
[Parameter(Mandatory = false)] | ||
public string ListUrl; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
var subscriber = new Microsoft.SharePoint.Client.Taxonomy.ContentTypeSync.ContentTypeSubscriber(ClientContext); | ||
ClientContext.Load(subscriber); | ||
ClientContext.ExecuteQueryRetry(); | ||
|
||
var results = subscriber.GetCompatibleHubContentTypes(WebUrl, ListUrl); | ||
ClientContext.ExecuteQueryRetry(); | ||
|
||
WriteObject(results, true); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.