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 #2893 from pnp/dev
Browse files Browse the repository at this point in the history
September 2020 Release
  • Loading branch information
erwinvanhunen authored Sep 7, 2020
2 parents 5f8e84e + 0395715 commit fd338f8
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 18 deletions.
Binary file modified Binaries/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
Binary file modified Binaries/release/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ 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.25.2009.0] (not yet released)

### Added
- Added ability to set site collection specific expiration on anonymous sharing links through the `-AnonymousLinkExpirationInDays` and `-OverrideTenantAnonymousLinkExpirationPolicy` attributes on `Set-PnPSite` and `Set-PnPTenantSite` [PR #2866](https://github.com/pnp/PnP-PowerShell/pull/2866)

### Changed


### Contributors
- Koen Zomers [koenzomers]

## [3.24.2008.1]

### Added
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ When you build the solution a postbuild script will copy the required files to a
To debug the cmdlets: launch PowerShell and attach Visual Studio to the powershell.exe process. In case you want to debug methods in PnP Sites Core, make sure that you open the PnP Sites Core project instead, and then attach Visual Studio to the powershell.exe. In case you see strange debug behavior, like it wants to debug PSReadLine.ps1, uninstall the PowerShell extension from Visual Studio.

## Keeping your fork up to date
Before starting on any new submissions, please ensure your fork is up to date with the upstream repository. This avoids frustration and challenges for us to valdate and test your submission. Steps on how to easily keep your fork up to date can be found [on this wiki page](https://github.com/pnp/PnP-PowerShell/wiki/Update-your-fork-with-the-latest-code).
Before starting on any new submissions, please ensure your fork is up to date with the upstream repository. This avoids frustration and challenges for us to validate and test your submission. Steps on how to easily keep your fork up to date can be found [on this wiki page](https://github.com/pnp/PnP-PowerShell/wiki/Update-your-fork-with-the-latest-code).

## Code contributions
In order to succesfully compile the PnP PowerShell solution you will _also_ have to download *and build in Visual Studio* the [PnP-Sites-Core](https://github.com/OfficeDev/PnP-Sites-Core) repository and make the dev branch available. The PowerShell solution depends on it. In order to succesfully
In order to successfully compile the PnP PowerShell solution you will _also_ have to download *and build in Visual Studio* the [PnP-Sites-Core](https://github.com/OfficeDev/PnP-Sites-Core) repository and make the dev branch available. The PowerShell solution depends on it. In order to successfully
compile it, make sure that PnP-Sites-Core is located at the same level as PnP-PowerShell and you open the solution file OfficeDevPnP.Core.sln located in the Core subfolder of the sourcecode.

So:
Expand All @@ -53,7 +53,7 @@ As documentation is autogenerated by building the solution, make sure that you i
```
### Most cmdlets will extend PnPCmdlet or PnPWebCmdlet which provides a few helper objects for you to use, like SelectedWeb and ClientContext
As most cmdlets are 'web sensitive' (e.g. you can specify a -Web parameter to point to a different subweb), make sure that you use the correct ClientContext. When a user specifies the -Web parameter
in a cmdlet that extens PnPWebCmdlet, the cmdlet will switch it's internal context to that web, reusing credentials. It is important to use the right context, and the easiest way to do that is to use
in a cmdlet that extends PnPWebCmdlet, the cmdlet will switch it's internal context to that web, reusing credentials. It is important to use the right context, and the easiest way to do that is to use

```csharp
var context = ClientContext
Expand Down
18 changes: 18 additions & 0 deletions Commands/Admin/SetTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public class SetTenantSite : PnPAdminCmdlet
[Parameter(Mandatory = false, HelpMessage = @"-", ParameterSetName = ParameterSet_PROPERTIES)]
public FlowsPolicy DisableFlows;

[Parameter(Mandatory = false, HelpMessage = @"Specifies all anonymous/anyone links that have been created (or will be created) will expire after the set number of days. Only applies if OverrideTenantAnonymousLinkExpirationPolicy is set to true. To remove the expiration requirement, set the value to zero (0).", ParameterSetName = ParameterSet_PROPERTIES)]
public int? AnonymousLinkExpirationInDays;

[Parameter(Mandatory = false, HelpMessage = @"Choose whether to override the anonymous or anyone link expiration policy on this site. False - Respect the organization-level policy for anonymous or anyone link expiration True - Override the organization-level policy for anonymous or anyone link expiration (can be more or less restrictive).", ParameterSetName = ParameterSet_PROPERTIES)]
public SwitchParameter OverrideTenantAnonymousLinkExpirationPolicy;

[Parameter(Mandatory = false, HelpMessage = "Wait for the operation to complete")]
public SwitchParameter Wait;
#endif
Expand Down Expand Up @@ -249,6 +255,18 @@ private void SetSiteProperties(Func<TenantOperationMessage, bool> timeoutFunctio
props.DisableFlows = DisableFlows;
updateRequired = true;
}

if (ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy)))
{
props.OverrideTenantAnonymousLinkExpirationPolicy = OverrideTenantAnonymousLinkExpirationPolicy.ToBool();
updateRequired = true;
}

if (ParameterSpecified(nameof(AnonymousLinkExpirationInDays)) && AnonymousLinkExpirationInDays.HasValue)
{
props.AnonymousLinkExpirationInDays = AnonymousLinkExpirationInDays.Value;
updateRequired = true;
}
#endif

if (updateRequired)
Expand Down
7 changes: 5 additions & 2 deletions Commands/Base/InitializePowerShellAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
using PnP.PowerShell.CmdletHelpAttributes;
using PnP.PowerShell.Commands.Model;
using PnP.PowerShell.Commands.Utilities;
using PnP.PowerShell.Commands.Utilities.REST;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Net.Http;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand Down Expand Up @@ -242,8 +244,9 @@ protected override void ProcessRecord()
},
requiredResourceAccess = scopesPayload
};
var postResult = HttpHelper.MakePostRequestForString("https://graph.microsoft.com/beta/applications", payload, "application/json", token);
var azureApp = JsonSerializer.Deserialize<AzureApp>(postResult);
var requestContent = new StringContent(JsonSerializer.Serialize(payload));
requestContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
var azureApp = GraphHelper.PostAsync<AzureApp>(new System.Net.Http.HttpClient(), "/beta/applications", requestContent, token).GetAwaiter().GetResult();
record.Properties.Add(new PSVariableProperty(new PSVariable("AzureAppId", azureApp.AppId)));

var waitTime = 60;
Expand Down
11 changes: 10 additions & 1 deletion Commands/Base/PnPConnectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,16 @@ internal static PnPConnection InstantiateWebloginConnection(Uri url, int minimal
{
using (var authManager = new OfficeDevPnP.Core.AuthenticationManager())
{
var context = PnPClientContext.ConvertFrom(authManager.GetWebLoginClientContext(url.ToString()), retryCount, retryWait * 1000);
// Log in to a specific page on the tenant which is known to be performant
var webLoginClientContext = authManager.GetWebLoginClientContext(url.ToString(), loginRequestUri: new Uri(url, "/_layouts/15/settings.aspx"));

// Ensure the login process has been completed
if(webLoginClientContext == null)
{
return null;
}

var context = PnPClientContext.ConvertFrom(webLoginClientContext, retryCount, retryWait * 1000);

if (context != null)
{
Expand Down
14 changes: 7 additions & 7 deletions Commands/Graph/GetMicrosoft365Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ namespace PnP.PowerShell.Commands.Graph
OutputTypeLink = "https://docs.microsoft.com/graph/api/group-list",
SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(
Code = "PS:> Get-Microsoft365Group",
Code = "PS:> Get-PnPMicrosoft365Group",
Remarks = "Retrieves all the Microsoft 365 Groups",
SortOrder = 1)]
[CmdletExample(
Code = "PS:> Get-Microsoft365Group -Identity $groupId",
Code = "PS:> Get-PnPMicrosoft365Group -Identity $groupId",
Remarks = "Retrieves a specific Microsoft 365 Group based on its ID",
SortOrder = 2)]
[CmdletExample(
Code = "PS:> Get-Microsoft365Group -Identity $groupDisplayName",
Code = "PS:> Get-PnPMicrosoft365Group -Identity $groupDisplayName",
Remarks = "Retrieves a specific or list of Microsoft 365 Groups that start with the given DisplayName",
SortOrder = 3)]
[CmdletExample(
Code = "PS:> Get-Microsoft365Group -Identity $groupSiteMailNickName",
Code = "PS:> Get-PnPMicrosoft365Group -Identity $groupSiteMailNickName",
Remarks = "Retrieves a specific or list of Microsoft 365 Groups for which the email starts with the provided mail nickName",
SortOrder = 4)]
[CmdletExample(
Code = "PS:> Get-Microsoft365Group -Identity $group",
Code = "PS:> Get-PnPMicrosoft365Group -Identity $group",
Remarks = "Retrieves a specific Microsoft 365 Group based on its object instance",
SortOrder = 5)]
[CmdletExample(
Code = "PS:> Get-Microsoft365Group -IncludeIfHasTeam",
Code = "PS:> Get-PnPMicrosoft365Group -IncludeHasTeam",
Remarks = "Retrieves all the Microsoft 365 Groups and checks for each of them if it has a Microsoft Team provisioned for it",
SortOrder = 6)]
[CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_Read_All | MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.GroupMember_ReadWrite_All | MicrosoftGraphApiPermission.GroupMember_Read_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All | MicrosoftGraphApiPermission.Directory_Read_All)]
Expand Down Expand Up @@ -80,4 +80,4 @@ protected override void ExecuteCmdlet()
}
}
}
#endif
#endif
4 changes: 2 additions & 2 deletions Commands/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
#if !PNPPSCORE
[assembly: AssemblyVersion("3.24.2008.1")]
[assembly: AssemblyFileVersion("3.24.2008.1")]
[assembly: AssemblyVersion("3.25.2009.0")]
[assembly: AssemblyFileVersion("3.25.2009.0")]
#else
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
Expand Down
22 changes: 20 additions & 2 deletions Commands/Site/SetSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public class SetSite : PnPSharePointCmdlet
[Parameter(Mandatory = false, HelpMessage = @"Disables or enables the Social Bar for Site Collection.", ParameterSetName = ParameterSet_PROPERTIES)]
public SwitchParameter? SocialBarOnSitePagesDisabled;

[Parameter(Mandatory = false, HelpMessage = @"Specifies all anonymous/anyone links that have been created (or will be created) will expire after the set number of days. Only applies if OverrideTenantAnonymousLinkExpirationPolicy is set to true. To remove the expiration requirement, set the value to zero (0).", ParameterSetName = ParameterSet_PROPERTIES)]
public int? AnonymousLinkExpirationInDays;

[Parameter(Mandatory = false, HelpMessage = @"Choose whether to override the anonymous or anyone link expiration policy on this site. False - Respect the organization-level policy for anonymous or anyone link expiration True - Override the organization-level policy for anonymous or anyone link expiration (can be more or less restrictive).", ParameterSetName = ParameterSet_PROPERTIES)]
public SwitchParameter OverrideTenantAnonymousLinkExpirationPolicy;

[Parameter(Mandatory = false, HelpMessage = "Wait for the operation to complete", ParameterSetName = ParameterSet_LOCKSTATE)]
public SwitchParameter Wait;
#endif
Expand Down Expand Up @@ -188,12 +194,12 @@ protected override void ExecuteCmdlet()
}
else
{
throw new System.Exception("Logo file does not exist");
throw new Exception("Logo file does not exist");
}
}
else
{
throw new System.Exception("Not an Office365 group enabled site.");
throw new Exception("Not an Office365 group enabled site.");
}
}
#endif
Expand Down Expand Up @@ -229,6 +235,16 @@ protected override void ExecuteCmdlet()
var siteProperties = tenant.GetSitePropertiesByUrl(siteUrl, false);

#if !ONPREMISES
if (ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy)))
{
siteProperties.OverrideTenantAnonymousLinkExpirationPolicy = OverrideTenantAnonymousLinkExpirationPolicy.ToBool();
executeQueryRequired = true;
}
if (ParameterSpecified(nameof(AnonymousLinkExpirationInDays)) && AnonymousLinkExpirationInDays.HasValue)
{
siteProperties.AnonymousLinkExpirationInDays = AnonymousLinkExpirationInDays.Value;
executeQueryRequired = true;
}
if (LockState.HasValue)
{
tenant.SetSiteLockState(siteUrl, LockState.Value, Wait, Wait ? timeoutFunction : null);
Expand Down Expand Up @@ -396,6 +412,8 @@ private bool IsTenantProperty() =>
#pragma warning restore CS0618 // Type or member is obsolete
RestrictedToGeo.HasValue ||
SocialBarOnSitePagesDisabled.HasValue ||
AnonymousLinkExpirationInDays.HasValue ||
ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy)) ||
#endif
LocaleId.HasValue;
}
Expand Down
8 changes: 8 additions & 0 deletions Commands/WebParts/GetWebPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ namespace PnP.PowerShell.Commands.WebParts
[CmdletExample(
Code = @"PS:> Get-PnPWebPart -ServerRelativePageUrl ""/sites/demo/sitepages/home.aspx"" -Identity a2875399-d6ff-43a0-96da-be6ae5875f82",
Remarks = @"Returns a specific web part defined on the given page.", SortOrder = 2)]
[CmdletExample(
Code = @"PS:> Get-PnPWebPart -ServerRelativePageUrl ""/sites/demo/sitepages/home.aspx"" | Where-Object {$_.WebPart.Title -Like ""*test*""}
Title Id
----- --
Apps in Testing a2875399-d6ff-43a0-96da-be6ae5875f82
Test Web Part e97c7058-4548-4129-bfee-c71ea5015da6",
Remarks = @"Returns all web parts with the word ""test"" in their Title on the given page.", SortOrder = 3)]
public class GetWebPart : PnPWebCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "Full server relative URL of the web part page, e.g. /sites/mysite/sitepages/home.aspx")]
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.24.2008.1
3.25.2009.0

0 comments on commit fd338f8

Please sign in to comment.