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

Commit

Permalink
Merge pull request #2348 from SharePoint/dev
Browse files Browse the repository at this point in the history
November 2019 Release
  • Loading branch information
erwinvanhunen authored Nov 8, 2019
2 parents e062ec4 + 412d208 commit 48af8f6
Show file tree
Hide file tree
Showing 57 changed files with 3,014 additions and 327 deletions.
Binary file modified Binaries/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
921 changes: 894 additions & 27 deletions Binaries/SharePointPnP.Modernization.Framework.xml

Large diffs are not rendered by default.

Binary file modified Binaries/release/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
921 changes: 894 additions & 27 deletions Binaries/release/SharePointPnP.Modernization.Framework.xml

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,34 @@ 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/).

## [Unreleased]
## [3.15.1911.0]

### Added

- Added Request-PnPAccessToken to retrieve an OAuth2 access token using the password grant.
- Added additional properties to Set-PnPHubSite
- Added Get-PnPHubSiteChild cmdlet to list all child sites of a hubsite
- ConvertTo-PnPClientSidePage: Added support for user mapping via `-UserMappingFile, `-LDAPConnectionString` and `-SkipUserMapping` parameters #2340
- ConvertTo-PnPClientSidePage: Added support for defining the target folder of a transformed page via `-TargetPageFolder`
- Added Get-PnPSearchSettings to retreive current search settings for a site
- Added Set-PnPSearchSettings to set search related settings on a site

### Changed

- Cmdlets related to provisioning and tenant templates now output more detailed error information in case of a schema issue.
- Fixes issue where site design was not being applied when using New-PnPSite
- Fixed incorrect usage of SwitchParameter in Set-PnPSite cmdlet
- Fixed issue when connecting to single level domain URLs
- Disabled TimeZone as mandatory parameter for New-PnPTenantSite when using an on-premises version of PnP PowerShell

### Contributors

- Gautam Sheth [gautamdsheth]
- Koen Zomers [KoenZomers]
- Laurens Hoogendoorn [laurens1984]
- Jens Otto Hatlevold [jensotto]
- Paul Bullock [pkbullock]

## [3.14.1910.1]

### Added
Expand Down
9 changes: 3 additions & 6 deletions Commands/Admin/GetHubSite.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Admin
Expand All @@ -22,11 +20,10 @@ public class GetHubSite : PnPAdminCmdlet

protected override void ExecuteCmdlet()
{
if (this.Identity != null)
if (Identity != null)
{
HubSiteProperties hubSiteProperties;
hubSiteProperties = base.Tenant.GetHubSitePropertiesByUrl(this.Identity.Url);
ClientContext.Load<HubSiteProperties>(hubSiteProperties);
var hubSiteProperties = Identity.GetHubSite(Tenant);
ClientContext.Load(hubSiteProperties);
ClientContext.ExecuteQueryRetry();
WriteObject(hubSiteProperties);
}
Expand Down
50 changes: 50 additions & 0 deletions Commands/Admin/GetHubSiteChild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System;
using System.Management.Automation;
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;

namespace SharePointPnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsCommon.Get, "PnPHubSiteChild")]
[CmdletHelp(@"Retrieves all sites linked to a specific hub site",
"Retrieves all sites linked to a specific hub site",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(Code = @"PS:> Get-PnPHubChildSite -Identity https://contoso.sharepoint.com/sites/myhubsite", Remarks = "Returns the sites having configured the provided hub site as their hub site", SortOrder = 1)]
public class GetHubSiteChild : PnPAdminCmdlet
{
[Parameter(ValueFromPipeline = true, Mandatory = true, HelpMessage = "The URL of the hubsite for which to receive the sites refering to it")]
public HubSitePipeBind Identity { get; set; }

protected override void ExecuteCmdlet()
{
HubSiteProperties hubSiteProperties;
try
{
hubSiteProperties = Identity.GetHubSite(Tenant);
ClientContext.Load(hubSiteProperties, h => h.ID);
ClientContext.ExecuteQueryRetry();
}
catch (ServerException ex)
{
if (ex.ServerErrorTypeName.Equals("System.IO.FileNotFoundException"))
{
throw new ArgumentException(Resources.SiteNotFound, nameof(Identity));
}

throw ex;
}

// Get the ID of the hubsite for which we need to find child sites
var hubSiteId = hubSiteProperties.ID;

WriteObject(Tenant.GetHubSiteChildUrls(hubSiteId), true);
}
}
}
#endif
2 changes: 1 addition & 1 deletion Commands/Admin/GrantHubSiteRights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class GrantHubSiteRights : PnPAdminCmdlet

protected override void ExecuteCmdlet()
{
base.Tenant.GrantHubSiteRights(Identity.Url, Principals, Rights);
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, Rights);
ClientContext.ExecuteQueryRetry();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Commands/Admin/NewSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected override void ExecuteCmdlet()
{
creationInformation.HubSiteId = HubSiteId.Id;
}
if (ParameterSetName == "CommunicationCustomInDesign")
if (ParameterSetName == ParameterSet_COMMUNICATIONCUSTOMDESIGN)
{
creationInformation.SiteDesignId = _communicationSiteParameters.SiteDesignId.Id;
}
Expand Down
4 changes: 4 additions & 0 deletions Commands/Admin/NewTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public class NewTenantSite : PnPAdminCmdlet
[Parameter(Mandatory = false, HelpMessage = @"Specifies the site collection template type. Use the Get-PnPWebTemplates cmdlet to get the list of valid templates. If no template is specified, one can be added later. The Template and LocaleId parameters must be a valid combination as returned from the Get-PnPWebTemplates cmdlet.")]
public string Template = "STS#0";

#if ONPREMISES
[Parameter(Mandatory = false, HelpMessage = "Use Get-PnPTimeZoneId to retrieve possible timezone values")]
#else
[Parameter(Mandatory = true, HelpMessage = "Use Get-PnPTimeZoneId to retrieve possible timezone values")]
#endif
public int TimeZone;

[Parameter(Mandatory = false, HelpMessage = @"Specifies the quota for this site collection in Sandboxed Solutions units. This value must not exceed the company's aggregate available Sandboxed Solutions quota. The default value is 0. For more information, see Resource Usage Limits on Sandboxed Solutions in SharePoint 2010 : http://msdn.microsoft.com/en-us/library/gg615462.aspx.")]
Expand Down
48 changes: 37 additions & 11 deletions Commands/Admin/SetHubSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,52 @@
namespace SharePointPnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsCommon.Set, "PnPHubSite")]
[CmdletHelp(@"Sets hubsite properties",
[CmdletHelp(@"Sets hub site properties", "Allows configuring a hub site",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(
Code = @"PS:> Set-PnPHubSite -Identity https://tenant.sharepoint.com/sites/myhubsite -Title ""My New Title""",
Remarks = "Sets the title of the hubsite",
Code = @"PS:> Set-PnPHubSite -Identity https://tenant.sharepoint.com/sites/myhubsite -Title ""My New Title""",
Remarks = "Sets the title of the hub site",
SortOrder = 1)]
[CmdletExample(
Code = @"PS:> Set-PnPHubSite -Identity https://tenant.sharepoint.com/sites/myhubsite -Description ""My updated description""",
Remarks = "Sets the description of the hub site",
SortOrder = 2)]
[CmdletExample(
Code = @"PS:> Set-PnPHubSite -Identity https://tenant.sharepoint.com/sites/myhubsite -SiteDesignId df8a3ef1-9603-44c4-abd9-541aea2fa745",
Remarks = "Sets the site design which should be applied to sites joining the the hub site",
SortOrder = 3)]
[CmdletExample(
Code = @"PS:> Set-PnPHubSite -Identity https://tenant.sharepoint.com/sites/myhubsite -LogoUrl ""https://tenant.sharepoint.com/SiteAssets/Logo.png""",
Remarks = "Sets the logo of the hub site",
SortOrder = 4)]
public class SetHubSite : PnPAdminCmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true)]
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true, HelpMessage = "The Id or Url of a hub site to configure")]
[Alias("HubSite")]
public HubSitePipeBind Identity { get; set; }

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "The title to set on the hub which will be shown in the hub navigation bar")]
public string Title { get; set; }

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Full url to the image to use for the hub site logo. Can either be a logo hosted on SharePoint or outside of SharePoint and must be an absolute URL to the image.")]
public string LogoUrl { get; set; }

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "The description of the hub site")]
public string Description { get; set; }

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "GUID of the SharePoint Site Design which should be applied when a site joins the hub site")]
public GuidPipeBind SiteDesignId;

[Parameter(Mandatory = false)]
public SwitchParameter HideNameInNavigation;

[Parameter(Mandatory = false)]
public SwitchParameter RequiresJoinApproval;

protected override void ExecuteCmdlet()
{
var hubSiteProperties = base.Tenant.GetHubSitePropertiesByUrl(this.Identity.Url);
var hubSiteProperties = Identity.GetHubSite(Tenant);
ClientContext.Load(hubSiteProperties);
if (MyInvocation.BoundParameters.ContainsKey("Title"))
{
Expand All @@ -47,11 +65,19 @@ protected override void ExecuteCmdlet()
}
if (MyInvocation.BoundParameters.ContainsKey("Description"))
{
hubSiteProperties.Description = this.Description;
hubSiteProperties.Description = Description;
}
if (MyInvocation.BoundParameters.ContainsKey("SiteDesignId"))
{
hubSiteProperties.SiteDesignId = this.SiteDesignId.Id;
hubSiteProperties.SiteDesignId = SiteDesignId.Id;
}
if (MyInvocation.BoundParameters.ContainsKey(nameof(HideNameInNavigation)))
{
hubSiteProperties.HideNameInNavigation = HideNameInNavigation.ToBool();
}
if (MyInvocation.BoundParameters.ContainsKey(nameof(RequiresJoinApproval)))
{
hubSiteProperties.RequiresJoinApproval = RequiresJoinApproval.ToBool();
}
hubSiteProperties.Update();
ClientContext.ExecuteQueryRetry();
Expand Down
16 changes: 13 additions & 3 deletions Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,18 +612,28 @@ protected override void ProcessRecord()
{
var jwtToken = new System.IdentityModel.Tokens.Jwt.JwtSecurityToken(AccessToken);
var aud = jwtToken.Audiences.FirstOrDefault();
var url = Url;
if (aud != null)
{
Url = aud;
url = aud;
}
if (Url.ToLower() == "https://graph.microsoft.com")
if (url.ToLower() == "https://graph.microsoft.com")
{
connection = ConnectGraphDeviceLogin(AccessToken);
}
else
{
Uri uri = null;
try
{
uri = new Uri(url);
}
catch
{
uri = new Uri(Url);
}
//#if !NETSTANDARD2_0
connection = SPOnlineConnectionHelper.InitiateAccessTokenConnection(new Uri(Url), AccessToken, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, NoTelemetry, SkipTenantAdminCheck, AzureEnvironment);
connection = SPOnlineConnectionHelper.InitiateAccessTokenConnection(uri, AccessToken, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, NoTelemetry, SkipTenantAdminCheck, AzureEnvironment);
//#else
//throw new NotImplementedException();
//#endif
Expand Down
4 changes: 2 additions & 2 deletions Commands/Base/GetException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ protected override void ProcessRecord()
{
foreach (ErrorRecord exception in exceptions)
{
output.Add(new PnPException() { Message = exception.Exception.Message, Stacktrace = exception.Exception.StackTrace, ScriptLineNumber = exception.InvocationInfo.ScriptLineNumber, InvocationInfo = exception.InvocationInfo });
output.Add(new PnPException() { Message = exception.Exception.Message, Stacktrace = exception.Exception.StackTrace, ScriptLineNumber = exception.InvocationInfo.ScriptLineNumber, InvocationInfo = exception.InvocationInfo, Exception = exception.Exception });
}
}
else
{
var exception = (ErrorRecord)exceptions[0];
output.Add(new PnPException() { Message = exception.Exception.Message, Stacktrace = exception.Exception.StackTrace, ScriptLineNumber = exception.InvocationInfo.ScriptLineNumber, InvocationInfo = exception.InvocationInfo });
output.Add(new PnPException() { Message = exception.Exception.Message, Stacktrace = exception.Exception.StackTrace, ScriptLineNumber = exception.InvocationInfo.ScriptLineNumber, InvocationInfo = exception.InvocationInfo, Exception = exception.Exception });
}
WriteObject(output, true);
}
Expand Down
55 changes: 55 additions & 0 deletions Commands/Base/PipeBinds/ApplyConfigurationPipeBind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.Framework.Provisioning.Model.Configuration;

namespace SharePointPnP.PowerShell.Commands.Base.PipeBinds
{
public sealed class ApplyConfigurationPipeBind
{
readonly ApplyConfiguration objectValue;
readonly string value;

public ApplyConfigurationPipeBind(string str)
{
value = str;
}

public ApplyConfigurationPipeBind(ApplyConfiguration configuration)
{
objectValue = configuration;
}

internal ApplyConfiguration GetConfiguration(string currentFileSystemLocation)
{
if (objectValue != null)
{
return objectValue;
}
if (!string.IsNullOrEmpty(value))
{
// is it a path?
try
{
string path = value;
if (!System.IO.Path.IsPathRooted(value))
{
path = System.IO.Path.Combine(currentFileSystemLocation, path);
}
if (System.IO.File.Exists(path))
{
return ApplyConfiguration.FromString(System.IO.File.ReadAllText(path));
}
else
{
return ApplyConfiguration.FromString(value);
}
}
catch
{
return null;
}
}
return null;
}
}
}
55 changes: 55 additions & 0 deletions Commands/Base/PipeBinds/ExtractConfigurationPipeBind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.Framework.Provisioning.Model.Configuration;

namespace SharePointPnP.PowerShell.Commands.Base.PipeBinds
{
public sealed class ExtractConfigurationPipeBind
{
readonly ExtractConfiguration objectValue;
readonly string value;

public ExtractConfigurationPipeBind(string str)
{
value = str;
}

public ExtractConfigurationPipeBind(ExtractConfiguration configuration)
{
objectValue = configuration;
}

internal ExtractConfiguration GetConfiguration(string currentFileSystemLocation)
{
if (objectValue != null)
{
return objectValue;
}
if (!string.IsNullOrEmpty(value))
{
// is it a path?
try
{
string path = value;
if (!System.IO.Path.IsPathRooted(value))
{
path = System.IO.Path.Combine(currentFileSystemLocation, path);
}
if (System.IO.File.Exists(path))
{
return ExtractConfiguration.FromString(System.IO.File.ReadAllText(path));
}
else
{
return ExtractConfiguration.FromString(value);
}
}
catch
{
return null;
}
}
return null;
}
}
}
Loading

0 comments on commit 48af8f6

Please sign in to comment.