Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2616 from pnp/dev
Browse files Browse the repository at this point in the history
April 2020 Release
  • Loading branch information
erwinvanhunen authored Apr 10, 2020
2 parents 3f994e7 + c053b05 commit 7174908
Show file tree
Hide file tree
Showing 61 changed files with 1,894 additions and 587 deletions.
36 changes: 33 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,39 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [3.19.2003.0] - Unreleased
## [3.20.2004.0]

### Added
- Added Set-PnPKnowledgeHubSite, Get-PnPKnowledgeHubSite and Remove-PnPKnowledgeHubSite cmdlets
- Added Register-PnPTenantAppCatalog to create and register a new Tenant App Catalog
- Added `IncludeHasTeam` flag to `Get-PnPUnifiedGroup` to include a `HasTeam` flag for each returned Office 365 Group indicating if a Microsoft Team has been set up for it [PR #2612](https://github.com/SharePoint/PnP-PowerShell/pull/2612)
- Added Initialize-PnPPowerShellAuthentication to create a new Azure AD App, self-signed certificate and set the appropriate permission scopes.

### Changed
- Connect-PnPOnline with clientid and certificate will now, if API permissions have been granted for the Graph work with the PnP Graph Cmdlets. [PR #2515](https://github.com/SharePoint/PnP-PowerShell/pull/2515)
- Save-PnPProvisioningTemplate and Save-PnPTenantTemplate now support XML file as input without the need to first read them into a variable with Read-PnPProvisioningTemplate or Read-PnPTenantTemplate
- Added -Schema parameter to Save-PnPProvisioningTemplate and Save-PnPTenantTemplate to force a specific schema for the embedded template. If not specified it defaults always to the latest released template.
- Fixed using `Connect-PnPOnline -PnPO365ManagementShell` only working if your default system language is English [PR #2613](https://github.com/SharePoint/PnP-PowerShell/pull/2613)
- Updated help text of 'Get-PnPClientSidePage' and 'Get-PnPClientSideComponent' to indicate that the out of the box homepage of a modern site will not return its contents as designed [PR #2592](https://github.com/SharePoint/PnP-PowerShell/pull/2592)
- Fixed using `Connect-PnPOnline -PnPO365ManagementShell` not working in PowerShell ISE [PR #2590](https://github.com/SharePoint/PnP-PowerShell/pull/2590)
- Uploading files using `Add-PnPFile` no longer requires Site Owner rights on the entire site. Read rights on the site and at least contribute rights on the document library where the file needs to be uploaded to will suffice as long as the target folder already exists. [PR #2478](https://github.com/SharePoint/PnP-PowerShell/pull/2478)
- Use of `Set-PnPSite` in combination with `-Owners`, `-NoScriptSite`, `-LocaleId` and/or `-AllowSelfServiceUpgrade` is now possible on SharePoint 2013, 2016 and 2019 as well [PR #2293](https://github.com/SharePoint/PnP-PowerShell/pull/2293)
- Using `Connect-PnPOnline -CurrentCredentials` against an on-premises SharePoint farm having more than one authentication provider configured on the webapplication no longer causes an access denied [PR #2571](https://github.com/SharePoint/PnP-PowerShell/pull/2571)
- Fixed `Add-PnPSiteDesignTask` not actually applying the Site Design to the site [PR #2542](https://github.com/SharePoint/PnP-PowerShell/pull/2542)
- Fixed `Get-PnPSiteDesignTask` throwing a collection not initialized error [PR #2545](https://github.com/SharePoint/PnP-PowerShell/pull/2545)

### Contributors
- Lane Blundell [fastlaneb]
- Markus Hanisch [Markus-Hanisch]
- Dan Myhre [danmyhre]
- Jens Otto Hatlevold [jensotto]
- Raphael [PowershellNinja]
- Razvan Hrestic [CodingSinceThe80s]
- Giacomo Pozzoni [jackpoz]
- [victorbutuza]
- Koen Zomers [koenzomers]

## [3.19.2003.0]

### Added
- Added `-HeaderLayoutType` option to `Add-PnPClientSidePage` which allows setting the header layout of a new Site Page [PR # 2514](https://github.com/SharePoint/PnP-PowerShell/pull/2514)
Expand All @@ -22,7 +54,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- The February 2020 release of PnP PowerShell was throwing an error on not being able to find and load the Newtonsoft assembly when used in an Azure Function. Fixed in this release.

### Contributors

- Arun Kumar Perumal [arunkumarperumal]
- Paul Bullock [pkbullock]
- Jens Otto Hatlevold [jensotto]
Expand Down Expand Up @@ -61,7 +92,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fix examples in Start-PnPWorkflowInstance [PR #2483](https://github.com/SharePoint/PnP-PowerShell/pull/2483)

### Contributors

- Ivan Vagunin [ivanvagunin]
- Thomas Meckel [tmeckel]
- Koen Zomers [koenzomers]
Expand Down
26 changes: 26 additions & 0 deletions Commands/Admin/GetKnowledgeHubSite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#if !ONPREMISES
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsCommon.Get, "PnPKnowledgeHubSite")]
[CmdletHelp("Gets the Knowledge Hub Site URL for your tenant",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Code = @"PS:> Get-PnPKnowledgeHubSite",
Remarks = @"Returns the Knowledge Hub Site Url for your tenant", SortOrder = 1)]
public class GetKnowledgeHubSite : PnPAdminCmdlet
{
protected override void ExecuteCmdlet()
{
var results = Tenant.GetKnowledgeHubSite();
Tenant.Context.ExecuteQueryRetry();
WriteObject(results.Value);
}
}
}
#endif
8 changes: 1 addition & 7 deletions Commands/Admin/GetTenant.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;
using OfficeDevPnP.Core.Sites;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System;
using SharePointPnP.PowerShell.Commands.Enums;
using System.Collections.Generic;
using SharePointPnP.PowerShell.Commands.Model;

namespace SharePointPnP.PowerShell.Commands.Admin
Expand All @@ -20,7 +14,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
Currently, there are no parameters for this cmdlet.
You must be a SharePoint Online global administrator to run the cmdlet.",
You must have the SharePoint Online admin or Global admin role to run the cmdlet.",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Expand Down
86 changes: 49 additions & 37 deletions Commands/Admin/GetTenantSite.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !ONPREMISES
#if !SP2013
using System;
using System.Linq;
using System.Management.Automation;
Expand All @@ -14,28 +14,33 @@ namespace SharePointPnP.PowerShell.Commands
[Cmdlet(VerbsCommon.Get, "PnPTenantSite", SupportsShouldProcess = true)]
[CmdletHelp(@"Retrieve site information.", "Use this cmdlet to retrieve site information from your tenant administration.",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online,
SupportedPlatform = CmdletSupportedPlatform.SP2016 | CmdletSupportedPlatform.SP2019 | CmdletSupportedPlatform.Online,
OutputType = typeof(Microsoft.Online.SharePoint.TenantAdministration.SiteProperties),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.siteproperties.aspx")]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite", Remarks = "Returns all site collections", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Url http://tenant.sharepoint.com/sites/projects", Remarks = "Returns information about the project site", SortOrder = 2)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Detailed", Remarks = "Returns all sites with the full details of these sites", SortOrder = 3)]
#if !ONPREMISES
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -IncludeOneDriveSites", Remarks = "Returns all sites including all OneDrive for Business sites", SortOrder = 4)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -IncludeOneDriveSites -Filter ""Url -like '-my.sharepoint.com/personal/'""", Remarks = "Returns all OneDrive for Business sites", SortOrder = 5)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Template SITEPAGEPUBLISHING#0", Remarks = "Returns all Communication sites", SortOrder = 6)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Filter ""Url -like 'sales'"" ", Remarks = "Returns all sites including 'sales' in the url", SortOrder = 7)]
#endif
public class GetTenantSite : PnPAdminCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "The URL of the site", Position = 0, ValueFromPipeline = true)]
[Alias("Identity")]
public string Url;

#if !ONPREMISES
[Parameter(Mandatory = false, HelpMessage = @"By default, all sites will be returned. Specify a template value alike ""STS#0"" here to filter on the template")]
public string Template;
#endif

[Parameter(Mandatory = false, HelpMessage = "By default, not all returned attributes are populated. This switch populates all attributes. It can take several seconds to run. Without this, some attributes will show default values that may not be correct.")]
public SwitchParameter Detailed;

#if !ONPREMISES
[Parameter(Mandatory = false, HelpMessage = "By default, the OneDrives are not returned. This switch includes all OneDrives.")]
public SwitchParameter IncludeOneDriveSites;

Expand All @@ -49,54 +54,61 @@ public class GetTenantSite : PnPAdminCmdlet

[Parameter(Mandatory = false, HelpMessage = "Specifies the script block of the server-side filter to apply. See https://technet.microsoft.com/en-us/library/fp161380.aspx")]
public string Filter;
#endif

protected override void ExecuteCmdlet()
{
if (SPOnlineConnection.CurrentConnection.ConnectionType == ConnectionType.OnPrem)
if (!string.IsNullOrEmpty(Url))
{
WriteObject(ClientContext.Site);
var list = Tenant.GetSitePropertiesByUrl(Url, Detailed);
list.Context.Load(list);
list.Context.ExecuteQueryRetry();
WriteObject(list, true);
}
else
{
if (!string.IsNullOrEmpty(Url))
#if !ONPREMISES
SPOSitePropertiesEnumerableFilter filter = new SPOSitePropertiesEnumerableFilter()
{
var list = Tenant.GetSitePropertiesByUrl(Url, Detailed);
list.Context.Load(list);
list.Context.ExecuteQueryRetry();
WriteObject(list, true);
}
else
{
SPOSitePropertiesEnumerableFilter filter = new SPOSitePropertiesEnumerableFilter()
{
IncludePersonalSite = IncludeOneDriveSites.IsPresent ? PersonalSiteFilter.Include : PersonalSiteFilter.UseServerDefault,
IncludeDetail = Detailed,
IncludePersonalSite = IncludeOneDriveSites.IsPresent ? PersonalSiteFilter.Include : PersonalSiteFilter.UseServerDefault,
IncludeDetail = Detailed,
#pragma warning disable CS0618 // Type or member is obsolete
Template = Template ?? WebTemplate,
Template = Template ?? WebTemplate,
#pragma warning restore CS0618 // Type or member is obsolete
Filter = Filter,
};
Filter = Filter,
};

SPOSitePropertiesEnumerable sitesList = null;
var sites = new List<SiteProperties>();
do
{
sitesList = Tenant.GetSitePropertiesFromSharePointByFilters(filter);
Tenant.Context.Load(sitesList);
Tenant.Context.ExecuteQueryRetry();
sites.AddRange(sitesList.ToList());
filter.StartIndex = sitesList.NextStartIndexFromSharePoint;
} while (!string.IsNullOrWhiteSpace(sitesList.NextStartIndexFromSharePoint));
#endif
SPOSitePropertiesEnumerable sitesList = null;
var sites = new List<SiteProperties>();
#if !ONPREMISES
do
{
sitesList = Tenant.GetSitePropertiesFromSharePointByFilters(filter);
Tenant.Context.Load(sitesList);
Tenant.Context.ExecuteQueryRetry();
sites.AddRange(sitesList.ToList());
filter.StartIndex = sitesList.NextStartIndexFromSharePoint;
} while (!string.IsNullOrWhiteSpace(sitesList.NextStartIndexFromSharePoint));
#else
sitesList = Tenant.GetSiteProperties(0, Detailed);
Tenant.Context.Load(sitesList);
Tenant.Context.ExecuteQueryRetry();
sites.AddRange(sitesList.ToList());
#endif

if (Template != null)
{
WriteObject(sites.Where(t => t.Template == Template).OrderBy(x => x.Url), true);
}
else
{
WriteObject(sites.OrderBy(x => x.Url), true);
}
#if !ONPREMISES
if (Template != null)
{
WriteObject(sites.Where(t => t.Template == Template).OrderBy(x => x.Url), true);
}
else
{
WriteObject(sites.OrderBy(x => x.Url), true);
}
#else
WriteObject(sites.OrderBy(x => x.Url), true);
#endif
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions Commands/Admin/GetWebTemplates.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
#if !ONPREMISES
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Get, "PnPWebTemplates")]
[CmdletHelp(@"Returns the available web templates.",
"Will list all available templates one can use to create a classic site.",
[CmdletHelp(@"Returns the available web templates",
"Will list all available templates one can use to create a site",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online,
OutputType =typeof(Microsoft.Online.SharePoint.TenantAdministration.SPOTenantWebTemplateCollection),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.spotenantwebtemplatecollection.aspx")]
SupportedPlatform = CmdletSupportedPlatform.All,
OutputType = typeof(Microsoft.Online.SharePoint.TenantAdministration.SPOTenantWebTemplateCollection),
OutputTypeLink = "https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/dn174817(v=office.15)")]
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates -LCID 1033", Remarks = @"Returns all webtemplates for the Locale with ID 1033 (English)", SortOrder = 2)]
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates -CompatibilityLevel 15", Remarks = @"Returns all webtemplates for the compatibility level 15", SortOrder = 2)]
[CmdletRelatedLink(Text = "Locale IDs", Url = "http://go.microsoft.com/fwlink/p/?LinkId=242911Id=242911")]
public class GetWebTemplates : PnPAdminCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "The language ID. For instance: 1033 for English")]
[Parameter(Mandatory = false, HelpMessage = "The language ID. For instance: 1033 for English.")]
public uint Lcid;

[Parameter(Mandatory = false, HelpMessage = "The version of SharePoint")]
Expand All @@ -31,4 +30,3 @@ protected override void ProcessRecord()
}
}
}
#endif
3 changes: 2 additions & 1 deletion Commands/Admin/NewSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using SharePointPnP.PowerShell.Commands.Enums;
using System;
using SharePointPnP.PowerShell.Commands.Base;

namespace SharePointPnP.PowerShell.Commands
{
Expand Down Expand Up @@ -160,7 +161,7 @@ protected override void ExecuteCmdlet()
}
creationInformation.Owners = _teamSiteParameters.Owners;

var returnedContext = OfficeDevPnP.Core.Sites.SiteCollection.Create(ClientContext, creationInformation, noWait:!Wait);
var returnedContext = OfficeDevPnP.Core.Sites.SiteCollection.Create(ClientContext, creationInformation, noWait:!Wait, graphAccessToken: SPOnlineConnection.CurrentConnection.AccessToken);
//var results = ClientContext.CreateSiteAsync(creationInformation);
//var returnedContext = results.GetAwaiter().GetResult();
WriteObject(returnedContext.Url);
Expand Down
2 changes: 2 additions & 0 deletions Commands/Admin/NewTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ protected override void ExecuteCmdlet()
#else
Func<TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;

#pragma warning disable CS0618 // Type or member is obsolete
if (ParameterSpecified(nameof(Description)))
#pragma warning restore CS0618 // Type or member is obsolete
{
// We have to fall back to synchronous behaviour as we have to wait for the site to be present in order to set the description.
Wait = true;
Expand Down
37 changes: 37 additions & 0 deletions Commands/Admin/RegisterAppCatalogSite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#if !ONPREMISES
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsLifecycle.Register, "PnPAppCatalogSite")]
[CmdletHelp("Creates a new App Catalog Site and sets this site as the Tenant App Catalog",
Category = CmdletHelpCategory.TenantAdmin, SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(
Code = @"PS:> Register-PnPAppCatalogSite -Url https://yourtenant.sharepoint.com/sites/appcatalog -Owner admin@domain.com -TimeZoneId 4",
Remarks = @"This will create a new appcatalog site if no app catalog is already present. Use -Force to create a new appcatalog site if one has already been registered. If using the same URL as an existing one and Force is present, the current/existing appcatalog site will be deleted.", SortOrder = 1)]
public class RegisterAppCatalogSite : PnPAdminCmdlet
{

[Parameter(Mandatory = true, HelpMessage = "The full url of the app catalog site to be created, e.g. https://yourtenant.sharepoint.com/sites/appcatalog")]
public string Url;

[Parameter(Mandatory = true, HelpMessage = "The login account of the user designated to be the admin for the site, e.g. user@domain.com")]
public string Owner;

[Parameter(Mandatory = true, HelpMessage = "Use Get-PnPTimeZoneId to retrieve possible timezone values")]
public int TimeZoneId;

[Parameter(Mandatory = false, HelpMessage ="If specified, and an app catalog is already present, a new app catalog site will be created. If the same URL is used the existing/current app catalog site will be deleted first.")]
public SwitchParameter Force;

protected override void ExecuteCmdlet()
{
WriteWarning("Notice that this cmdlet can take considerate time to finish executing.");
Tenant.EnsureAppCatalogAsync(Url, Owner, TimeZoneId, Force).GetAwaiter().GetResult();
}
}
}
#endif
Loading

0 comments on commit 7174908

Please sign in to comment.