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

Commit

Permalink
Merge pull request #2569 from SharePoint/dev
Browse files Browse the repository at this point in the history
March 2020 Release
  • Loading branch information
erwinvanhunen authored Mar 10, 2020
2 parents ad7e28e + c19b7f4 commit 3f994e7
Show file tree
Hide file tree
Showing 22 changed files with 2,689 additions and 2,105 deletions.
Binary file modified Binaries/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
2,252 changes: 1,235 additions & 1,017 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.
2,252 changes: 1,235 additions & 1,017 deletions Binaries/release/SharePointPnP.Modernization.Framework.xml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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/).

## [3.19.2003.0] - Unreleased

### 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)
- Added `TermMappingFile` and `SkipTermStoreMapping` parameters to the `ConvertTo-PnPClientSidePage` cmdlet for supporting managed metadata mapping
- 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)
- 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)

### Changed
- 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)
- 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)
- Marked the -Rights parameter as obsolete on Grant-PnPHubSiteRights. Use Revoke-PnPHubSiteRights to revoke rights for specific users to join sites ot the hubsite
- 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).
- 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)
- 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]
- Pepe [ingepepe]
- [bjdekker]
- [N4TheKing]
- Koen Zomers [koenzomers]
- kadu-jr
- [a1mery]

## [3.18.2002.0]

### Added
Expand Down
32 changes: 27 additions & 5 deletions Commands/Admin/GrantHubSiteRights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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 @@ -12,8 +13,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
[CmdletHelp(@"Grant additional permissions to the permissions already in place to associate sites to Hub Sites for one or more specific users",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[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)]
[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)]
[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)]
public class GrantHubSiteRights : PnPAdminCmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true, HelpMessage = "The Hub Site to set the permissions on to associate another site with this Hub Site")]
Expand All @@ -23,12 +23,34 @@ public class GrantHubSiteRights : PnPAdminCmdlet
[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.")]
public string[] Principals { get; set; }

[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")]
public SPOHubSiteUserRights Rights { get; set; }
[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")]
[Obsolete("Use Revoke-PnPHubSiteRights to revoke rights and Grant-PnPHubSiteRights without the -Rights parameter to grant rights")]
public SPOHubSiteUserRights Rights { get; set; } = SPOHubSiteUserRights.Join;

protected override void ExecuteCmdlet()
{
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, Rights);
if (MyInvocation.BoundParameters.ContainsKey("Rights"))
{
#pragma warning disable CS0618 // Type or member is obsolete
switch (Rights)
{
case SPOHubSiteUserRights.Join:
{
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, SPOHubSiteUserRights.Join);
break;
}
case SPOHubSiteUserRights.None:
{
base.Tenant.RevokeHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals);
break;
}
}
}
#pragma warning restore CS0618 // Type or member is obsolete
else
{
base.Tenant.GrantHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals, SPOHubSiteUserRights.Join);
}
ClientContext.ExecuteQueryRetry();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Commands/Admin/RemoveTenantCdnOrigin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Code = @"PS:> Remove-PnPTenantCdnOrigin -Url /sites/site/subfolder -CdnType Public",
Code = @"PS:> Remove-PnPTenantCdnOrigin -OriginUrl /sites/site/subfolder -CdnType Public",
Remarks = @"This example removes the specified origin from the public CDN", SortOrder = 1)]
public class RemoveTenantCdnOrigin : PnPAdminCmdlet
{
Expand All @@ -35,4 +35,4 @@ protected override void ExecuteCmdlet()
}
}
}
#endif
#endif
33 changes: 33 additions & 0 deletions Commands/Admin/RevokeHubSiteRights.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#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
{
[Cmdlet(VerbsSecurity.Revoke, "PnPHubSiteRights")]
[CmdletHelp(@"Revoke permissions to the permissions already in place to associate sites to Hub Sites for one or more specific users",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[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)]
public class RevokeHubSiteRights : PnPAdminCmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true, HelpMessage = "The Hub Site to revoke the permissions on to associate another site with this Hub Site")]
[Alias("HubSite")]
public HubSitePipeBind Identity { get; set; }

[Parameter(Mandatory = true, HelpMessage = "One or more usernames that will be revoked the permission to associate a site with this Hub Site.")]
public string[] Principals { get; set; }

protected override void ExecuteCmdlet()
{
base.Tenant.RevokeHubSiteRights(Identity.Url ?? Identity.GetHubSite(Tenant).SiteUrl, Principals);
ClientContext.ExecuteQueryRetry();
}
}
}
#endif
28 changes: 25 additions & 3 deletions Commands/Base/BasePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,22 @@ protected override void EndProcessing()

private void FixAssemblyResolving()
{
newtonsoftAssembly = Assembly.LoadFrom(Path.Combine(AssemblyDirectory, "NewtonSoft.Json.dll"));
var newtonsoftAssemblyByLocation = Path.Combine(AssemblyDirectoryFromLocation, "Newtonsoft.Json.dll");
if (File.Exists(newtonsoftAssemblyByLocation))
{
// Local run, network run, etc.
newtonsoftAssembly = Assembly.LoadFrom(newtonsoftAssemblyByLocation);
}
else
{
// Running from Azure Function
var newtonsoftAssemblyByCodeBase = Path.Combine(AssemblyDirectoryFromCodeBase, "Newtonsoft.Json.dll");
newtonsoftAssembly = Assembly.LoadFrom(newtonsoftAssemblyByCodeBase);
}
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}

private string AssemblyDirectory
private string AssemblyDirectoryFromLocation
{
get
{
Expand All @@ -37,9 +48,20 @@ private string AssemblyDirectory
}
}

private string AssemblyDirectoryFromCodeBase
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}

private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.StartsWith("Newtonsoft.Json"))
if (args.Name.StartsWith("NewtonSoft.Json", StringComparison.InvariantCultureIgnoreCase))
{
return newtonsoftAssembly;
}
Expand Down
19 changes: 15 additions & 4 deletions Commands/ClientSidePages/AddClientSidePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
[CmdletExample(
Code = @"PS:> Add-PnPClientSidePage -Name ""Folder/NewPage""",
Remarks = "Creates a new Client-Side page named 'NewPage' under 'Folder' folder and saves as a template to the site.",
SortOrder = 3)]
SortOrder = 3)]
#if !ONPREMISES
[CmdletExample(
Code = @"PS:> Add-PnPClientSidePage -Name ""NewPage"" -HeaderLayoutType ColorBlock",
Remarks = "Creates a new Client-Side page named 'NewPage' using the ColorBlock header layout",
SortOrder = 4)]
#endif
public class AddClientSidePage : PnPWebCmdlet
{
[Parameter(Mandatory = true, Position = 0, HelpMessage = "Specifies the name of the page.")]
Expand All @@ -47,17 +53,19 @@ public class AddClientSidePage : PnPWebCmdlet
[Parameter(Mandatory = false, HelpMessage = "Publishes the page once it is saved. Applicable to libraries set to create major and minor versions.")]
public SwitchParameter Publish;

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

protected override void ExecuteCmdlet()
{

ClientSidePage clientSidePage = null;

// Check if the page exists

string name = ClientSidePageUtilities.EnsureCorrectPageName(Name);

bool pageExists = false;
Expand All @@ -76,6 +84,10 @@ protected override void ExecuteCmdlet()
// Create a page that persists immediately
clientSidePage = SelectedWeb.AddClientSidePage(name);
clientSidePage.LayoutType = LayoutType;

#if !ONPREMISES
clientSidePage.PageHeader.LayoutType = HeaderLayoutType;
#endif
if (PromoteAs == ClientSidePagePromoteType.Template)
{
clientSidePage.SaveAsTemplate(name);
Expand Down Expand Up @@ -127,7 +139,6 @@ protected override void ExecuteCmdlet()
break;
}


if (ParameterSpecified(nameof(CommentsEnabled)))
{
if (CommentsEnabled)
Expand Down
16 changes: 16 additions & 0 deletions Commands/ClientSidePages/ConvertToClientSidePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public class ConvertToClientSidePage : PnPWebCmdlet
[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")]
public SwitchParameter TargetPageFolderOverridesDefaultFolder = false;

[Parameter(Mandatory = false, HelpMessage = "Remove empty sections and columns after transformation of the page")]
public SwitchParameter RemoveEmptySectionsAndColumns = true;

[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'
public SPOnlineConnection TargetConnection = null;

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

[Parameter(Mandatory = false, HelpMessage = "Specifies a taxonomy term mapping file")]
public string TermMappingFile = "";

[Parameter(Mandatory = false, HelpMessage = "Disables term mapping during transformation")]
public SwitchParameter SkipTermStoreMapping = false;

[Parameter(Mandatory = false, HelpMessage = "Specifies a LDAP connection string e.g. LDAP://OU=Users,DC=Contoso,DC=local")]
public string LDAPConnectionString = "";

Expand Down Expand Up @@ -443,6 +452,9 @@ protected override void ExecuteCmdlet()
LDAPConnectionString = this.LDAPConnectionString,
TargetPageFolder = this.TargetPageFolder,
TargetPageFolderOverridesDefaultFolder = this.TargetPageFolderOverridesDefaultFolder,
TermMappingFile = TermMappingFile,
SkipTermStoreMapping = SkipTermStoreMapping,
RemoveEmptySectionsAndColumns = this.RemoveEmptySectionsAndColumns
};

// Set mapping properties
Expand Down Expand Up @@ -484,6 +496,7 @@ protected override void ExecuteCmdlet()
LDAPConnectionString = this.LDAPConnectionString,
TargetPageFolder = this.TargetPageFolder,
TargetPageFolderOverridesDefaultFolder = this.TargetPageFolderOverridesDefaultFolder,
RemoveEmptySectionsAndColumns = this.RemoveEmptySectionsAndColumns
};

// Set mapping properties
Expand Down Expand Up @@ -543,6 +556,9 @@ protected override void ExecuteCmdlet()
{
AddPageAcceptBanner = this.AddPageAcceptBanner
},
TermMappingFile = TermMappingFile,
SkipTermStoreMapping = SkipTermStoreMapping,
RemoveEmptySectionsAndColumns = this.RemoveEmptySectionsAndColumns
};

// Set mapping properties
Expand Down
19 changes: 6 additions & 13 deletions Commands/Fields/AddField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using OfficeDevPnP.Core.Entities;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System.Collections;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace SharePointPnP.PowerShell.Commands.Fields
Expand All @@ -15,13 +13,14 @@ namespace SharePointPnP.PowerShell.Commands.Fields
"Adds a field to a list or as a site column",
Category = CmdletHelpCategory.Fields,
OutputType = typeof(Field),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.field.aspx")]
OutputTypeLink = "https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ee545882(v=office.15)",
SupportedPlatform = CmdletSupportedPlatform.All)]
[CmdletExample(
Code = @"PS:> Add-PnPField -List ""Demo list"" -DisplayName ""Location"" -InternalName ""SPSLocation"" -Type Choice -Group ""Demo Group"" -AddToDefaultView -Choices ""Stockholm"",""Helsinki"",""Oslo""",
Remarks = @"This will add a field of type Choice to the list ""Demo List"".", SortOrder = 1)]
Code = @"PS:> Add-PnPField -List ""Demo list"" -DisplayName ""Location"" -InternalName ""SPSLocation"" -Type Choice -Group ""Demo Group"" -AddToDefaultView -Choices ""Stockholm"",""Helsinki"",""Oslo""",
Remarks = @"This will add a field of type Choice to the list ""Demo List"".", SortOrder = 1)]
[CmdletExample(
Code = @"PS:>Add-PnPField -List ""Demo list"" -DisplayName ""Speakers"" -InternalName ""SPSSpeakers"" -Type MultiChoice -Group ""Demo Group"" -AddToDefaultView -Choices ""Obiwan Kenobi"",""Darth Vader"", ""Anakin Skywalker""",
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)]
Code = @"PS:>Add-PnPField -List ""Demo list"" -DisplayName ""Speakers"" -InternalName ""SPSSpeakers"" -Type MultiChoice -Group ""Demo Group"" -AddToDefaultView -Choices ""Obiwan Kenobi"",""Darth Vader"", ""Anakin Skywalker""",
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)]
[CmdletExample(
Code = @"PS:> Add-PnPField -Type Calculated -InternalName ""C1"" -DisplayName ""C1"" -Formula =""[Title]""",
Remarks = @"Adds a new calculated site column with the formula specified")]
Expand Down Expand Up @@ -81,10 +80,6 @@ public class AddField : PnPWebCmdlet, IDynamicParameters
public string ClientSideComponentProperties;
#endif

[Parameter(Mandatory = false)]
[Obsolete("Not in use")]
public AddFieldOptions FieldOptions = AddFieldOptions.DefaultValue;

public object GetDynamicParameters()
{
if (Type == FieldType.Choice || Type == FieldType.MultiChoice)
Expand Down Expand Up @@ -366,7 +361,5 @@ public class CalculatedFieldDynamicParameters
[Parameter(Mandatory = false)]
public string ResultType;
}

}

}
Loading

0 comments on commit 3f994e7

Please sign in to comment.