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

Commit 3f994e7

Browse files
Merge pull request #2569 from SharePoint/dev
March 2020 Release
2 parents ad7e28e + c19b7f4 commit 3f994e7

22 files changed

+2689
-2105
lines changed
Binary file not shown.

Binaries/SharePointPnP.Modernization.Framework.xml

+1,235-1,017
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

Binaries/release/SharePointPnP.Modernization.Framework.xml

+1,235-1,017
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
55

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

8+
## [3.19.2003.0] - Unreleased
9+
10+
### Added
11+
- 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)
12+
- Added `TermMappingFile` and `SkipTermStoreMapping` parameters to the `ConvertTo-PnPClientSidePage` cmdlet for supporting managed metadata mapping
13+
- Added `AsFileObject` parameter to `Get-PnPFile` which allows the result to be returned as file objects instead of list iems [PR # 2550](https://github.com/SharePoint/PnP-PowerShell/pull/2550)
14+
- Added `RemoveEmptySectionsAndColumns` parameter to the `ConvertTo-PnPClientSidePage` cmdlet for allowing for empty sections and columns to stay after conversion [PR # 2539](https://github.com/SharePoint/PnP-PowerShell/pull/2539)
15+
16+
### Changed
17+
- Fixed issue where downloading a file using `Get-PnPFile` would throw an user not found exception if the user having created or having last modified the file no longer existed [PR #2504](https://github.com/SharePoint/PnP-PowerShell/pull/2504)
18+
- Removed `FieldOptions` argument from `Add-PnPField` as it was marked as obsolete since 2015 already and wasn't used anymore [PR # 2497](https://github.com/SharePoint/PnP-PowerShell/pull/2497)
19+
- Marked the -Rights parameter as obsolete on Grant-PnPHubSiteRights. Use Revoke-PnPHubSiteRights to revoke rights for specific users to join sites ot the hubsite
20+
- Output just the URL for the Redirect url in Get-PnPSearchSettings. Return web setting on sc root as fallback if sc setting is missing (via core).
21+
- Made it possible to set property bag value on a NoScript site using `Set-PnPPropertyBagValue` by providing the argument `Folder` and specifying something other than the root folder [PR # 2544](https://github.com/SharePoint/PnP-PowerShell/pull/2544)
22+
- 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.
23+
24+
### Contributors
25+
26+
- Arun Kumar Perumal [arunkumarperumal]
27+
- Paul Bullock [pkbullock]
28+
- Jens Otto Hatlevold [jensotto]
29+
- Pepe [ingepepe]
30+
- [bjdekker]
31+
- [N4TheKing]
32+
- Koen Zomers [koenzomers]
33+
- kadu-jr
34+
- [a1mery]
35+
836
## [3.18.2002.0]
937

1038
### Added

Commands/Admin/GrantHubSiteRights.cs

+27-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using SharePointPnP.PowerShell.CmdletHelpAttributes;
55
using SharePointPnP.PowerShell.Commands.Base;
66
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7+
using System;
78
using System.Management.Automation;
89

910
namespace SharePointPnP.PowerShell.Commands.Admin
@@ -12,8 +13,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
1213
[CmdletHelp(@"Grant additional permissions to the permissions already in place to associate sites to Hub Sites for one or more specific users",
1314
Category = CmdletHelpCategory.TenantAdmin,
1415
SupportedPlatform = CmdletSupportedPlatform.Online)]
15-
[CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""[email protected]"",""[email protected]"" -Rights Join", Remarks = "This example shows how to grant rights to myuser and myotheruser to associate their sites with the provided Hub Site", SortOrder = 1)]
16-
[CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""[email protected]"" -Rights None", Remarks = "This example shows how to revoke rights from myuser to associate their sites with the provided Hub Site", SortOrder = 2)]
16+
[CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""[email protected]"",""[email protected]""", Remarks = "This example shows how to grant rights to myuser and myotheruser to associate their sites with the provided Hub Site", SortOrder = 1)]
1717
public class GrantHubSiteRights : PnPAdminCmdlet
1818
{
1919
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true, HelpMessage = "The Hub Site to set the permissions on to associate another site with this Hub Site")]
@@ -23,12 +23,34 @@ public class GrantHubSiteRights : PnPAdminCmdlet
2323
[Parameter(Mandatory = true, HelpMessage = "One or more usernames that will be given or revoked the permission to associate a site with this Hub Site. It does not replace permissions given out before but adds to the already existing permissions.")]
2424
public string[] Principals { get; set; }
2525

26-
[Parameter(Mandatory = true, HelpMessage = "Provide Join to give permissions to associate a site with this Hub Site or use None to revoke the permissions for the user(s) specified with the Principals argument")]
27-
public SPOHubSiteUserRights Rights { get; set; }
26+
[Parameter(Mandatory = false, HelpMessage = "Provide Join to give permissions to associate a site with this Hub Site or use None to revoke the permissions for the user(s) specified with the Principals argument")]
27+
[Obsolete("Use Revoke-PnPHubSiteRights to revoke rights and Grant-PnPHubSiteRights without the -Rights parameter to grant rights")]
28+
public SPOHubSiteUserRights Rights { get; set; } = SPOHubSiteUserRights.Join;
2829

2930
protected override void ExecuteCmdlet()
3031
{
31-
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, Rights);
32+
if (MyInvocation.BoundParameters.ContainsKey("Rights"))
33+
{
34+
#pragma warning disable CS0618 // Type or member is obsolete
35+
switch (Rights)
36+
{
37+
case SPOHubSiteUserRights.Join:
38+
{
39+
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, SPOHubSiteUserRights.Join);
40+
break;
41+
}
42+
case SPOHubSiteUserRights.None:
43+
{
44+
base.Tenant.RevokeHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals);
45+
break;
46+
}
47+
}
48+
}
49+
#pragma warning restore CS0618 // Type or member is obsolete
50+
else
51+
{
52+
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, SPOHubSiteUserRights.Join);
53+
}
3254
ClientContext.ExecuteQueryRetry();
3355
}
3456
}

Commands/Admin/RemoveTenantCdnOrigin.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
1818
SupportedPlatform = CmdletSupportedPlatform.Online,
1919
Category = CmdletHelpCategory.TenantAdmin)]
2020
[CmdletExample(
21-
Code = @"PS:> Remove-PnPTenantCdnOrigin -Url /sites/site/subfolder -CdnType Public",
21+
Code = @"PS:> Remove-PnPTenantCdnOrigin -OriginUrl /sites/site/subfolder -CdnType Public",
2222
Remarks = @"This example removes the specified origin from the public CDN", SortOrder = 1)]
2323
public class RemoveTenantCdnOrigin : PnPAdminCmdlet
2424
{
@@ -35,4 +35,4 @@ protected override void ExecuteCmdlet()
3535
}
3636
}
3737
}
38-
#endif
38+
#endif

Commands/Admin/RevokeHubSiteRights.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#if !ONPREMISES
2+
using Microsoft.Online.SharePoint.TenantAdministration;
3+
using Microsoft.SharePoint.Client;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
5+
using SharePointPnP.PowerShell.Commands.Base;
6+
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7+
using System;
8+
using System.Management.Automation;
9+
10+
namespace SharePointPnP.PowerShell.Commands.Admin
11+
{
12+
[Cmdlet(VerbsSecurity.Revoke, "PnPHubSiteRights")]
13+
[CmdletHelp(@"Revoke permissions to the permissions already in place to associate sites to Hub Sites for one or more specific users",
14+
Category = CmdletHelpCategory.TenantAdmin,
15+
SupportedPlatform = CmdletSupportedPlatform.Online)]
16+
[CmdletExample(Code = @"PS:> Revoke-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""[email protected]"",""[email protected]""", Remarks = "This example shows how to revoke the rights of myuser and myotheruser to associate their sites with the provided Hub Site", SortOrder = 1)]
17+
public class RevokeHubSiteRights : PnPAdminCmdlet
18+
{
19+
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true, HelpMessage = "The Hub Site to revoke the permissions on to associate another site with this Hub Site")]
20+
[Alias("HubSite")]
21+
public HubSitePipeBind Identity { get; set; }
22+
23+
[Parameter(Mandatory = true, HelpMessage = "One or more usernames that will be revoked the permission to associate a site with this Hub Site.")]
24+
public string[] Principals { get; set; }
25+
26+
protected override void ExecuteCmdlet()
27+
{
28+
base.Tenant.RevokeHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals);
29+
ClientContext.ExecuteQueryRetry();
30+
}
31+
}
32+
}
33+
#endif

Commands/Base/BasePSCmdlet.cs

+25-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,22 @@ protected override void EndProcessing()
2323

2424
private void FixAssemblyResolving()
2525
{
26-
newtonsoftAssembly = Assembly.LoadFrom(Path.Combine(AssemblyDirectory, "NewtonSoft.Json.dll"));
26+
var newtonsoftAssemblyByLocation = Path.Combine(AssemblyDirectoryFromLocation, "Newtonsoft.Json.dll");
27+
if (File.Exists(newtonsoftAssemblyByLocation))
28+
{
29+
// Local run, network run, etc.
30+
newtonsoftAssembly = Assembly.LoadFrom(newtonsoftAssemblyByLocation);
31+
}
32+
else
33+
{
34+
// Running from Azure Function
35+
var newtonsoftAssemblyByCodeBase = Path.Combine(AssemblyDirectoryFromCodeBase, "Newtonsoft.Json.dll");
36+
newtonsoftAssembly = Assembly.LoadFrom(newtonsoftAssemblyByCodeBase);
37+
}
2738
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
2839
}
2940

30-
private string AssemblyDirectory
41+
private string AssemblyDirectoryFromLocation
3142
{
3243
get
3344
{
@@ -37,9 +48,20 @@ private string AssemblyDirectory
3748
}
3849
}
3950

51+
private string AssemblyDirectoryFromCodeBase
52+
{
53+
get
54+
{
55+
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
56+
UriBuilder uri = new UriBuilder(codeBase);
57+
string path = Uri.UnescapeDataString(uri.Path);
58+
return Path.GetDirectoryName(path);
59+
}
60+
}
61+
4062
private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
4163
{
42-
if (args.Name.StartsWith("Newtonsoft.Json"))
64+
if (args.Name.StartsWith("NewtonSoft.Json", StringComparison.InvariantCultureIgnoreCase))
4365
{
4466
return newtonsoftAssembly;
4567
}

Commands/ClientSidePages/AddClientSidePage.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
2626
[CmdletExample(
2727
Code = @"PS:> Add-PnPClientSidePage -Name ""Folder/NewPage""",
2828
Remarks = "Creates a new Client-Side page named 'NewPage' under 'Folder' folder and saves as a template to the site.",
29-
SortOrder = 3)]
29+
SortOrder = 3)]
30+
#if !ONPREMISES
31+
[CmdletExample(
32+
Code = @"PS:> Add-PnPClientSidePage -Name ""NewPage"" -HeaderLayoutType ColorBlock",
33+
Remarks = "Creates a new Client-Side page named 'NewPage' using the ColorBlock header layout",
34+
SortOrder = 4)]
35+
#endif
3036
public class AddClientSidePage : PnPWebCmdlet
3137
{
3238
[Parameter(Mandatory = true, Position = 0, HelpMessage = "Specifies the name of the page.")]
@@ -47,17 +53,19 @@ public class AddClientSidePage : PnPWebCmdlet
4753
[Parameter(Mandatory = false, HelpMessage = "Publishes the page once it is saved. Applicable to libraries set to create major and minor versions.")]
4854
public SwitchParameter Publish;
4955

56+
#if !ONPREMISES
57+
[Parameter(Mandatory = false, HelpMessage = "Type of layout used for the header")]
58+
public ClientSidePageHeaderLayoutType HeaderLayoutType = ClientSidePageHeaderLayoutType.FullWidthImage;
59+
#endif
5060
[Obsolete("This parameter will be ignored")]
5161
[Parameter(Mandatory = false, HelpMessage = "Sets the message for publishing the page.")]
5262
public string PublishMessage = string.Empty;
5363

5464
protected override void ExecuteCmdlet()
5565
{
56-
5766
ClientSidePage clientSidePage = null;
5867

5968
// Check if the page exists
60-
6169
string name = ClientSidePageUtilities.EnsureCorrectPageName(Name);
6270

6371
bool pageExists = false;
@@ -76,6 +84,10 @@ protected override void ExecuteCmdlet()
7684
// Create a page that persists immediately
7785
clientSidePage = SelectedWeb.AddClientSidePage(name);
7886
clientSidePage.LayoutType = LayoutType;
87+
88+
#if !ONPREMISES
89+
clientSidePage.PageHeader.LayoutType = HeaderLayoutType;
90+
#endif
7991
if (PromoteAs == ClientSidePagePromoteType.Template)
8092
{
8193
clientSidePage.SaveAsTemplate(name);
@@ -127,7 +139,6 @@ protected override void ExecuteCmdlet()
127139
break;
128140
}
129141

130-
131142
if (ParameterSpecified(nameof(CommentsEnabled)))
132143
{
133144
if (CommentsEnabled)

Commands/ClientSidePages/ConvertToClientSidePage.cs

+16
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ public class ConvertToClientSidePage : PnPWebCmdlet
193193
[Parameter(Mandatory = false, HelpMessage = "When setting a target page folder then the target page folder overrides possibly default folder path (e.g. in the source page lived in a folder) instead of being appended to it")]
194194
public SwitchParameter TargetPageFolderOverridesDefaultFolder = false;
195195

196+
[Parameter(Mandatory = false, HelpMessage = "Remove empty sections and columns after transformation of the page")]
197+
public SwitchParameter RemoveEmptySectionsAndColumns = true;
198+
196199
[Parameter(Mandatory = false, HelpMessage = "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.")] // do not remove '#!#99'
197200
public SPOnlineConnection TargetConnection = null;
198201

@@ -202,6 +205,12 @@ public class ConvertToClientSidePage : PnPWebCmdlet
202205
[Parameter(Mandatory = false, HelpMessage = "Specifies a user mapping file")]
203206
public string UserMappingFile = "";
204207

208+
[Parameter(Mandatory = false, HelpMessage = "Specifies a taxonomy term mapping file")]
209+
public string TermMappingFile = "";
210+
211+
[Parameter(Mandatory = false, HelpMessage = "Disables term mapping during transformation")]
212+
public SwitchParameter SkipTermStoreMapping = false;
213+
205214
[Parameter(Mandatory = false, HelpMessage = "Specifies a LDAP connection string e.g. LDAP://OU=Users,DC=Contoso,DC=local")]
206215
public string LDAPConnectionString = "";
207216

@@ -443,6 +452,9 @@ protected override void ExecuteCmdlet()
443452
LDAPConnectionString = this.LDAPConnectionString,
444453
TargetPageFolder = this.TargetPageFolder,
445454
TargetPageFolderOverridesDefaultFolder = this.TargetPageFolderOverridesDefaultFolder,
455+
TermMappingFile = TermMappingFile,
456+
SkipTermStoreMapping = SkipTermStoreMapping,
457+
RemoveEmptySectionsAndColumns = this.RemoveEmptySectionsAndColumns
446458
};
447459

448460
// Set mapping properties
@@ -484,6 +496,7 @@ protected override void ExecuteCmdlet()
484496
LDAPConnectionString = this.LDAPConnectionString,
485497
TargetPageFolder = this.TargetPageFolder,
486498
TargetPageFolderOverridesDefaultFolder = this.TargetPageFolderOverridesDefaultFolder,
499+
RemoveEmptySectionsAndColumns = this.RemoveEmptySectionsAndColumns
487500
};
488501

489502
// Set mapping properties
@@ -543,6 +556,9 @@ protected override void ExecuteCmdlet()
543556
{
544557
AddPageAcceptBanner = this.AddPageAcceptBanner
545558
},
559+
TermMappingFile = TermMappingFile,
560+
SkipTermStoreMapping = SkipTermStoreMapping,
561+
RemoveEmptySectionsAndColumns = this.RemoveEmptySectionsAndColumns
546562
};
547563

548564
// Set mapping properties

Commands/Fields/AddField.cs

+6-13
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
using OfficeDevPnP.Core.Entities;
55
using SharePointPnP.PowerShell.CmdletHelpAttributes;
66
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7-
using System.Collections;
8-
using Newtonsoft.Json;
97
using System.Collections.Generic;
108

119
namespace SharePointPnP.PowerShell.Commands.Fields
@@ -15,13 +13,14 @@ namespace SharePointPnP.PowerShell.Commands.Fields
1513
"Adds a field to a list or as a site column",
1614
Category = CmdletHelpCategory.Fields,
1715
OutputType = typeof(Field),
18-
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.field.aspx")]
16+
OutputTypeLink = "https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ee545882(v=office.15)",
17+
SupportedPlatform = CmdletSupportedPlatform.All)]
1918
[CmdletExample(
20-
Code = @"PS:> Add-PnPField -List ""Demo list"" -DisplayName ""Location"" -InternalName ""SPSLocation"" -Type Choice -Group ""Demo Group"" -AddToDefaultView -Choices ""Stockholm"",""Helsinki"",""Oslo""",
21-
Remarks = @"This will add a field of type Choice to the list ""Demo List"".", SortOrder = 1)]
19+
Code = @"PS:> Add-PnPField -List ""Demo list"" -DisplayName ""Location"" -InternalName ""SPSLocation"" -Type Choice -Group ""Demo Group"" -AddToDefaultView -Choices ""Stockholm"",""Helsinki"",""Oslo""",
20+
Remarks = @"This will add a field of type Choice to the list ""Demo List"".", SortOrder = 1)]
2221
[CmdletExample(
23-
Code = @"PS:>Add-PnPField -List ""Demo list"" -DisplayName ""Speakers"" -InternalName ""SPSSpeakers"" -Type MultiChoice -Group ""Demo Group"" -AddToDefaultView -Choices ""Obiwan Kenobi"",""Darth Vader"", ""Anakin Skywalker""",
24-
Remarks = @"This will add a field of type Multiple Choice to the list ""Demo List"". (you can pick several choices for the same item)", SortOrder = 2)]
22+
Code = @"PS:>Add-PnPField -List ""Demo list"" -DisplayName ""Speakers"" -InternalName ""SPSSpeakers"" -Type MultiChoice -Group ""Demo Group"" -AddToDefaultView -Choices ""Obiwan Kenobi"",""Darth Vader"", ""Anakin Skywalker""",
23+
Remarks = @"This will add a field of type Multiple Choice to the list ""Demo List"". (you can pick several choices for the same item)", SortOrder = 2)]
2524
[CmdletExample(
2625
Code = @"PS:> Add-PnPField -Type Calculated -InternalName ""C1"" -DisplayName ""C1"" -Formula =""[Title]""",
2726
Remarks = @"Adds a new calculated site column with the formula specified")]
@@ -81,10 +80,6 @@ public class AddField : PnPWebCmdlet, IDynamicParameters
8180
public string ClientSideComponentProperties;
8281
#endif
8382

84-
[Parameter(Mandatory = false)]
85-
[Obsolete("Not in use")]
86-
public AddFieldOptions FieldOptions = AddFieldOptions.DefaultValue;
87-
8883
public object GetDynamicParameters()
8984
{
9085
if (Type == FieldType.Choice || Type == FieldType.MultiChoice)
@@ -366,7 +361,5 @@ public class CalculatedFieldDynamicParameters
366361
[Parameter(Mandatory = false)]
367362
public string ResultType;
368363
}
369-
370364
}
371-
372365
}

0 commit comments

Comments
 (0)