diff --git a/CHANGELOG.md b/CHANGELOG.md index a1405a150..8e0d9f471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `-AsMemoryStream` option to `Get-PnPFile` to allow for downloading of a file from SharePoint Online in memory for further processing [#1638](https://github.com/pnp/powershell/pull/1638) - Added `-Stream` option to `Read-PnPSiteTemplate` to allow for processing on a PnP Provisioning Template coming from memory [#1638](https://github.com/pnp/powershell/pull/1638) - Added `-Force` option to `Set-PnPTenant` to allow skipping the confirmation question for certain other parameters like `SignInAccelerationDomain,EnableGuestSignInAcceleration,BccExternalSharingInvitations,OrphanedPersonalSitesRetentionPeriod,OneDriveForGuestsEnabled,AllowDownloadingNonWebViewableFiles`. +- Added `Get-PnPCompatibleHubContentTypes` which allows the list of content types present in the content type hub site that can be added to the root web or a list on a target site to be returned [#1678](https://github.com/pnp/powershell/pull/1678) ### Changed diff --git a/documentation/Get-PnPCompatibleHubContentTypes.md b/documentation/Get-PnPCompatibleHubContentTypes.md new file mode 100644 index 000000000..ffef1ad54 --- /dev/null +++ b/documentation/Get-PnPCompatibleHubContentTypes.md @@ -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 [-ListUrl ] [-Connection ] [] +``` + +## 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) \ No newline at end of file diff --git a/src/Commands/ContentTypes/GetCompatibleHubContentTypes.cs b/src/Commands/ContentTypes/GetCompatibleHubContentTypes.cs new file mode 100644 index 000000000..cce72847f --- /dev/null +++ b/src/Commands/ContentTypes/GetCompatibleHubContentTypes.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/src/Commands/ContentTypes/Get-PnPContentTypePublishingStatus.cs b/src/Commands/ContentTypes/GetContentTypePublishingStatus.cs similarity index 100% rename from src/Commands/ContentTypes/Get-PnPContentTypePublishingStatus.cs rename to src/Commands/ContentTypes/GetContentTypePublishingStatus.cs diff --git a/src/Commands/ContentTypes/Publish-PnPContentType.cs b/src/Commands/ContentTypes/PublishContentType.cs similarity index 100% rename from src/Commands/ContentTypes/Publish-PnPContentType.cs rename to src/Commands/ContentTypes/PublishContentType.cs diff --git a/src/Commands/ContentTypes/Unpublish-PnPContentType.cs b/src/Commands/ContentTypes/UnpublishContentType.cs similarity index 100% rename from src/Commands/ContentTypes/Unpublish-PnPContentType.cs rename to src/Commands/ContentTypes/UnpublishContentType.cs