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

Commit fd338f8

Browse files
Merge pull request #2893 from pnp/dev
September 2020 Release
2 parents 5f8e84e + 0395715 commit fd338f8

12 files changed

+85
-18
lines changed
Binary file not shown.
Binary file not shown.

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ 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.25.2009.0] (not yet released)
9+
10+
### Added
11+
- 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)
12+
13+
### Changed
14+
15+
16+
### Contributors
17+
- Koen Zomers [koenzomers]
18+
819
## [3.24.2008.1]
920

1021
### Added

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ When you build the solution a postbuild script will copy the required files to a
2323
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.
2424

2525
## Keeping your fork up to date
26-
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).
26+
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).
2727

2828
## Code contributions
29-
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
29+
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
3030
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.
3131

3232
So:
@@ -53,7 +53,7 @@ As documentation is autogenerated by building the solution, make sure that you i
5353
```
5454
### Most cmdlets will extend PnPCmdlet or PnPWebCmdlet which provides a few helper objects for you to use, like SelectedWeb and ClientContext
5555
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
56-
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
56+
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
5757

5858
```csharp
5959
var context = ClientContext

Commands/Admin/SetTenantSite.cs

+18
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public class SetTenantSite : PnPAdminCmdlet
111111
[Parameter(Mandatory = false, HelpMessage = @"-", ParameterSetName = ParameterSet_PROPERTIES)]
112112
public FlowsPolicy DisableFlows;
113113

114+
[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)]
115+
public int? AnonymousLinkExpirationInDays;
116+
117+
[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)]
118+
public SwitchParameter OverrideTenantAnonymousLinkExpirationPolicy;
119+
114120
[Parameter(Mandatory = false, HelpMessage = "Wait for the operation to complete")]
115121
public SwitchParameter Wait;
116122
#endif
@@ -249,6 +255,18 @@ private void SetSiteProperties(Func<TenantOperationMessage, bool> timeoutFunctio
249255
props.DisableFlows = DisableFlows;
250256
updateRequired = true;
251257
}
258+
259+
if (ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy)))
260+
{
261+
props.OverrideTenantAnonymousLinkExpirationPolicy = OverrideTenantAnonymousLinkExpirationPolicy.ToBool();
262+
updateRequired = true;
263+
}
264+
265+
if (ParameterSpecified(nameof(AnonymousLinkExpirationInDays)) && AnonymousLinkExpirationInDays.HasValue)
266+
{
267+
props.AnonymousLinkExpirationInDays = AnonymousLinkExpirationInDays.Value;
268+
updateRequired = true;
269+
}
252270
#endif
253271

254272
if (updateRequired)

Commands/Base/InitializePowerShellAuthentication.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
using PnP.PowerShell.CmdletHelpAttributes;
55
using PnP.PowerShell.Commands.Model;
66
using PnP.PowerShell.Commands.Utilities;
7+
using PnP.PowerShell.Commands.Utilities.REST;
78
using System;
89
using System.Collections.Generic;
910
using System.IO;
1011
using System.Linq;
1112
using System.Management.Automation;
1213
using System.Management.Automation.Host;
14+
using System.Net.Http;
1315
using System.Security;
1416
using System.Security.Cryptography;
1517
using System.Security.Cryptography.X509Certificates;
@@ -242,8 +244,9 @@ protected override void ProcessRecord()
242244
},
243245
requiredResourceAccess = scopesPayload
244246
};
245-
var postResult = HttpHelper.MakePostRequestForString("https://graph.microsoft.com/beta/applications", payload, "application/json", token);
246-
var azureApp = JsonSerializer.Deserialize<AzureApp>(postResult);
247+
var requestContent = new StringContent(JsonSerializer.Serialize(payload));
248+
requestContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
249+
var azureApp = GraphHelper.PostAsync<AzureApp>(new System.Net.Http.HttpClient(), "/beta/applications", requestContent, token).GetAwaiter().GetResult();
247250
record.Properties.Add(new PSVariableProperty(new PSVariable("AzureAppId", azureApp.AppId)));
248251

249252
var waitTime = 60;

Commands/Base/PnPConnectionHelper.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,16 @@ internal static PnPConnection InstantiateWebloginConnection(Uri url, int minimal
529529
{
530530
using (var authManager = new OfficeDevPnP.Core.AuthenticationManager())
531531
{
532-
var context = PnPClientContext.ConvertFrom(authManager.GetWebLoginClientContext(url.ToString()), retryCount, retryWait * 1000);
532+
// Log in to a specific page on the tenant which is known to be performant
533+
var webLoginClientContext = authManager.GetWebLoginClientContext(url.ToString(), loginRequestUri: new Uri(url, "/_layouts/15/settings.aspx"));
534+
535+
// Ensure the login process has been completed
536+
if(webLoginClientContext == null)
537+
{
538+
return null;
539+
}
540+
541+
var context = PnPClientContext.ConvertFrom(webLoginClientContext, retryCount, retryWait * 1000);
533542

534543
if (context != null)
535544
{

Commands/Graph/GetMicrosoft365Group.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ namespace PnP.PowerShell.Commands.Graph
1616
OutputTypeLink = "https://docs.microsoft.com/graph/api/group-list",
1717
SupportedPlatform = CmdletSupportedPlatform.Online)]
1818
[CmdletExample(
19-
Code = "PS:> Get-Microsoft365Group",
19+
Code = "PS:> Get-PnPMicrosoft365Group",
2020
Remarks = "Retrieves all the Microsoft 365 Groups",
2121
SortOrder = 1)]
2222
[CmdletExample(
23-
Code = "PS:> Get-Microsoft365Group -Identity $groupId",
23+
Code = "PS:> Get-PnPMicrosoft365Group -Identity $groupId",
2424
Remarks = "Retrieves a specific Microsoft 365 Group based on its ID",
2525
SortOrder = 2)]
2626
[CmdletExample(
27-
Code = "PS:> Get-Microsoft365Group -Identity $groupDisplayName",
27+
Code = "PS:> Get-PnPMicrosoft365Group -Identity $groupDisplayName",
2828
Remarks = "Retrieves a specific or list of Microsoft 365 Groups that start with the given DisplayName",
2929
SortOrder = 3)]
3030
[CmdletExample(
31-
Code = "PS:> Get-Microsoft365Group -Identity $groupSiteMailNickName",
31+
Code = "PS:> Get-PnPMicrosoft365Group -Identity $groupSiteMailNickName",
3232
Remarks = "Retrieves a specific or list of Microsoft 365 Groups for which the email starts with the provided mail nickName",
3333
SortOrder = 4)]
3434
[CmdletExample(
35-
Code = "PS:> Get-Microsoft365Group -Identity $group",
35+
Code = "PS:> Get-PnPMicrosoft365Group -Identity $group",
3636
Remarks = "Retrieves a specific Microsoft 365 Group based on its object instance",
3737
SortOrder = 5)]
3838
[CmdletExample(
39-
Code = "PS:> Get-Microsoft365Group -IncludeIfHasTeam",
39+
Code = "PS:> Get-PnPMicrosoft365Group -IncludeHasTeam",
4040
Remarks = "Retrieves all the Microsoft 365 Groups and checks for each of them if it has a Microsoft Team provisioned for it",
4141
SortOrder = 6)]
4242
[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)]
@@ -80,4 +80,4 @@ protected override void ExecuteCmdlet()
8080
}
8181
}
8282
}
83-
#endif
83+
#endif

Commands/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
// by using the '*' as shown below:
5252
// [assembly: AssemblyVersion("1.0.*")]
5353
#if !PNPPSCORE
54-
[assembly: AssemblyVersion("3.24.2008.1")]
55-
[assembly: AssemblyFileVersion("3.24.2008.1")]
54+
[assembly: AssemblyVersion("3.25.2009.0")]
55+
[assembly: AssemblyFileVersion("3.25.2009.0")]
5656
#else
5757
[assembly: AssemblyVersion("4.0.0.0")]
5858
[assembly: AssemblyFileVersion("4.0.0.0")]

Commands/Site/SetSite.cs

+20-2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public class SetSite : PnPSharePointCmdlet
128128
[Parameter(Mandatory = false, HelpMessage = @"Disables or enables the Social Bar for Site Collection.", ParameterSetName = ParameterSet_PROPERTIES)]
129129
public SwitchParameter? SocialBarOnSitePagesDisabled;
130130

131+
[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)]
132+
public int? AnonymousLinkExpirationInDays;
133+
134+
[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)]
135+
public SwitchParameter OverrideTenantAnonymousLinkExpirationPolicy;
136+
131137
[Parameter(Mandatory = false, HelpMessage = "Wait for the operation to complete", ParameterSetName = ParameterSet_LOCKSTATE)]
132138
public SwitchParameter Wait;
133139
#endif
@@ -188,12 +194,12 @@ protected override void ExecuteCmdlet()
188194
}
189195
else
190196
{
191-
throw new System.Exception("Logo file does not exist");
197+
throw new Exception("Logo file does not exist");
192198
}
193199
}
194200
else
195201
{
196-
throw new System.Exception("Not an Office365 group enabled site.");
202+
throw new Exception("Not an Office365 group enabled site.");
197203
}
198204
}
199205
#endif
@@ -229,6 +235,16 @@ protected override void ExecuteCmdlet()
229235
var siteProperties = tenant.GetSitePropertiesByUrl(siteUrl, false);
230236

231237
#if !ONPREMISES
238+
if (ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy)))
239+
{
240+
siteProperties.OverrideTenantAnonymousLinkExpirationPolicy = OverrideTenantAnonymousLinkExpirationPolicy.ToBool();
241+
executeQueryRequired = true;
242+
}
243+
if (ParameterSpecified(nameof(AnonymousLinkExpirationInDays)) && AnonymousLinkExpirationInDays.HasValue)
244+
{
245+
siteProperties.AnonymousLinkExpirationInDays = AnonymousLinkExpirationInDays.Value;
246+
executeQueryRequired = true;
247+
}
232248
if (LockState.HasValue)
233249
{
234250
tenant.SetSiteLockState(siteUrl, LockState.Value, Wait, Wait ? timeoutFunction : null);
@@ -396,6 +412,8 @@ private bool IsTenantProperty() =>
396412
#pragma warning restore CS0618 // Type or member is obsolete
397413
RestrictedToGeo.HasValue ||
398414
SocialBarOnSitePagesDisabled.HasValue ||
415+
AnonymousLinkExpirationInDays.HasValue ||
416+
ParameterSpecified(nameof(OverrideTenantAnonymousLinkExpirationPolicy)) ||
399417
#endif
400418
LocaleId.HasValue;
401419
}

Commands/WebParts/GetWebPart.cs

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ namespace PnP.PowerShell.Commands.WebParts
2121
[CmdletExample(
2222
Code = @"PS:> Get-PnPWebPart -ServerRelativePageUrl ""/sites/demo/sitepages/home.aspx"" -Identity a2875399-d6ff-43a0-96da-be6ae5875f82",
2323
Remarks = @"Returns a specific web part defined on the given page.", SortOrder = 2)]
24+
[CmdletExample(
25+
Code = @"PS:> Get-PnPWebPart -ServerRelativePageUrl ""/sites/demo/sitepages/home.aspx"" | Where-Object {$_.WebPart.Title -Like ""*test*""}
26+
27+
Title Id
28+
----- --
29+
Apps in Testing a2875399-d6ff-43a0-96da-be6ae5875f82
30+
Test Web Part e97c7058-4548-4129-bfee-c71ea5015da6",
31+
Remarks = @"Returns all web parts with the word ""test"" in their Title on the given page.", SortOrder = 3)]
2432
public class GetWebPart : PnPWebCmdlet
2533
{
2634
[Parameter(Mandatory = true, HelpMessage = "Full server relative URL of the web part page, e.g. /sites/mysite/sitepages/home.aspx")]

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.24.2008.1
1+
3.25.2009.0

0 commit comments

Comments
 (0)