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 #3022 from pnp/dev
Browse files Browse the repository at this point in the history
December 2020 Release
  • Loading branch information
erwinvanhunen authored Dec 8, 2020
2 parents 7318423 + 99f8d0f commit 5f4fdeb
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 36 deletions.
Binary file modified Binaries/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
8 changes: 4 additions & 4 deletions Binaries/SharePointPnP.Modernization.Framework.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Binaries/release/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
8 changes: 4 additions & 4 deletions Binaries/release/SharePointPnP.Modernization.Framework.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ 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.26.2010.0 - unreleased]
## [3.28.2012.0]

### Added

### Changed
- Small fixes to README.md
- Fixed several issues with `Get-PnPSubwebs` and introduced optional parameter `-IncludeRootWeb` to include the rootweb in the results
- Change in `Copy-PnPFile` which should resolve some issues you may run into when copying files [PR #2796](https://github.com/pnp/PnP-PowerShell/pull/2796)
- Changed fallback scenario for 'Get-PnPFile' where downloading a file created by a user that no longer exists would try a different technique to download the file. This only worked on English environments though. With this fix, it should work for any language. [PR #2852](https://github.com/pnp/PnP-PowerShell/pull/2852)

### Contributors
- David Blaszyk [acornsoft]
- Koen Zomers [koenzomers]
- Carlos Marins Jr [kadu-jr]
- Heinrich Ulbricht [heinrich-ulbricht]

## [3.26.2010.0]

### Added
- Added `Set-PnPTenant -EnableAutoNewsDigest` option to disable the automatic news digest mails sent to end users [PR #2901](https://github.com/pnp/PnP-PowerShell/pull/2901)
Expand Down
8 changes: 8 additions & 0 deletions Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@ protected void Connect()
Url = Url.Substring(0, Url.Length - 1);
}

#if !ONPREMISES
if (!PnPConnectionHelper.LegacyMessageShown)
{
WriteUpdateMessage("\nYou are running the legacy version of PnP PowerShell.\nThis version will be archived soon which means that while staying available, no updates or fixes will be released.\nConsider installing the newer prereleased cross-platform version of PnP PowerShell:\n\nUninstall-Module -Name SharePointPnPPowerShellOnline -AllVersions -Force\nInstall-Module -Name PnP.PowerShell -AllowPrerelease\n\nRead more about the new cross-platform version of PnP PowerShell at\n\nhttps://pnp.github.io/powershell\n\nThe new version of PnP PowerShell will be released as 1.0 in January 2021.\n");
PnPConnectionHelper.LegacyMessageShown = true;
}
#endif

PnPConnection connection = null;

var latestVersion = PnPConnectionHelper.GetLatestVersion();
Expand Down
1 change: 1 addition & 0 deletions Commands/Base/PnPConnectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal class PnPConnectionHelper
private static readonly Uri VersionCheckUrl = new Uri("https://raw.githubusercontent.com/pnp/PnP-PowerShell/master/version.txt");
#endif
private static bool VersionChecked;
internal static bool LegacyMessageShown;

#if !PNPPSCORE
public static AuthenticationContext AuthContext { get; set; }
Expand Down
8 changes: 3 additions & 5 deletions Commands/Base/RegisterPnPManagementShellAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ public class RegisterPnPManagementShellAccess : PSCmdlet
public AzureEnvironment AzureEnvironment = AzureEnvironment.Production;

[Parameter(Mandatory = true)]
[Obsolete("This parameter will be ignored")]
public string SiteUrl;
protected override void ProcessRecord()
{
var endPoint = GenericToken.GetAzureADLoginEndPoint(AzureEnvironment);
var uri = new Uri(SiteUrl);
var scopes = new[] { $"{uri.Scheme}://{uri.Authority}//.default" };


var application = PublicClientApplicationBuilder.Create(PnPConnection.PnPManagementShellClientId).WithAuthority($"{endPoint}/organizations/").WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient").Build();

var result = application.AcquireTokenInteractive(scopes).ExecuteAsync().GetAwaiter().GetResult();
result = application.AcquireTokenInteractive(new[] { "https://graph.microsoft.com/.default" }).ExecuteAsync().GetAwaiter().GetResult();
application.AcquireTokenInteractive(new[] { "https://graph.microsoft.com/.default" }).ExecuteAsync().GetAwaiter().GetResult();

}
}
Expand Down
8 changes: 8 additions & 0 deletions Commands/Fields/AddField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public class AddField : PnPWebCmdlet, IDynamicParameters
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ADDFIELDBYXMLTOLIST, HelpMessage = "The group name to where this field belongs to")]
public string Group;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ADDFIELDTOLIST, HelpMessage = "Switch Parameter if this field must be added to all content types")]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ADDFIELDBYXMLTOLIST, HelpMessage = "Switch Parameter if this field must be added to all content types")]
public SwitchParameter AddToAllContentTypes;

#if !ONPREMISES
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ADDFIELDTOLIST, HelpMessage = "The Client Side Component Id to set to the field")]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ADDFIELDTOWEB, HelpMessage = "The Client Side Component Id to set to the field")]
Expand Down Expand Up @@ -122,6 +126,10 @@ protected override void ExecuteCmdlet()
Group = Group,
AddToDefaultView = AddToDefaultView
};

if (AddToAllContentTypes)
fieldCI.FieldOptions |= AddFieldOptions.AddToAllContentTypes;

#if !ONPREMISES
if (ClientSideComponentId != null)
{
Expand Down
3 changes: 2 additions & 1 deletion Commands/Files/CopyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ protected override void ExecuteCmdlet()
TargetUrl = UrlUtility.Combine(webServerRelativeUrl, TargetUrl);
}

string sourceFolder = SourceUrl.Substring(0, SourceUrl.LastIndexOf('/'));
Uri currentContextUri = new Uri(ClientContext.Url);
Uri sourceUri = new Uri(currentContextUri, SourceUrl);
Uri sourceUri = new Uri(currentContextUri, sourceFolder);
Uri sourceWebUri = Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect(ClientContext, sourceUri);
Uri targetUri = new Uri(currentContextUri, TargetUrl);
Uri targetWebUri = Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect(ClientContext, targetUri);
Expand Down
3 changes: 2 additions & 1 deletion Commands/Files/GetFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ protected override void ExecuteCmdlet()
ClientContext.Load(file, f => f.Author, f => f.Length, f => f.ModifiedBy, f => f.Name, f => f.TimeCreated, f => f.TimeLastModified, f => f.Title);
ClientContext.ExecuteQueryRetry();
}
catch (ServerException e) when (e.Message == "User cannot be found.")
catch (ServerException)
{
// Assume the cause of the exception is that a principal cannot be found and try again without:
// Fallback in case the creator or person having last modified the file no longer exists in the environment such that the file can still be downloaded
ClientContext.Load(file, f => f.Length, f => f.Name, f => f.TimeCreated, f => f.TimeLastModified, f => f.Title);
ClientContext.ExecuteQueryRetry();
Expand Down
6 changes: 6 additions & 0 deletions Commands/Model/AzureApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ public PermissionScopes()
Id = "3db89e36-7fa6-4012-b281-85f3d9d9fd2e",
Identifier = "MSGraph.AppCatalog.Submit"
});
scopes.Add(new PermissionScope()
{
resourceAppId = "00000003-0000-0000-c000-000000000000",
Id = "19dbc75e-c2e2-444c-a770-ec69d8559fc7",
Identifier = "MSGraph.Directory.ReadWrite.All"
});
#endregion
#region SPO
// SPO
Expand Down
10 changes: 8 additions & 2 deletions Commands/PnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,11 @@
</Otherwise>
</Choose>
<ItemGroup>
<Reference Include="AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL">
<HintPath>..\packages\AngleSharp.0.9.9\lib\net45\AngleSharp.dll</HintPath>
<Reference Include="AngleSharp, Version=0.14.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL">
<HintPath>..\packages\AngleSharp.0.14.0\lib\net461\AngleSharp.dll</HintPath>
</Reference>
<Reference Include="AngleSharp.Css, Version=0.14.2.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea, processorArchitecture=MSIL">
<HintPath>..\packages\AngleSharp.Css.0.14.2\lib\net461\AngleSharp.Css.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationInsights, Version=2.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ApplicationInsights.2.8.1\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
Expand Down Expand Up @@ -535,6 +538,9 @@
<Reference Include="System.Spatial, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.8.4\lib\net40\System.Spatial.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.4.5.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.4.7.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
Expand Down
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.26.2010.0")]
[assembly: AssemblyFileVersion("3.26.2010.0")]
[assembly: AssemblyVersion("3.28.2012.0")]
[assembly: AssemblyFileVersion("3.28.2012.0")]
#else
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion Commands/Search/GetSearchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ RefinableString100 1000000900
*/
int p;
if (!int.TryParse(pid, out p)) return pid;
if (p <= 1000000000) return pid;
if (p < 1000000000) return pid;

var autoMpNum = pid.Substring(pid.Length - 2);
var mpName = pid;
Expand Down
2 changes: 1 addition & 1 deletion Commands/Utilities/TeamsUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public static async Task<TeamChannel> AddChannelAsync(string accessToken, HttpCl
channel.Type = "#Microsoft.Teams.Core.channel";
var user = await GraphHelper.GetAsync<User>(httpClient, $"v1.0/users/{ownerUPN}", accessToken);
channel.Members = new List<TeamChannelMember>();
channel.Members.Add(new TeamChannelMember() { Roles = new List<string> { "owner" }, UserIdentifier = $"https://graph.microsoft.com/beta/users/('{user.Id}')" });
channel.Members.Add(new TeamChannelMember() { Roles = new List<string> { "owner" }, UserIdentifier = $"https://graph.microsoft.com/beta/users('{user.Id}')" });
return await GraphHelper.PostAsync<TeamChannel>(httpClient, $"beta/teams/{groupId}/channels", channel, accessToken);
}
else
Expand Down
64 changes: 54 additions & 10 deletions Commands/Web/GetSubwebs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace PnP.PowerShell.Commands
[CmdletHelp("Returns the subwebs of the current web",
Category = CmdletHelpCategory.Webs,
OutputType = typeof(Web),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.aspx")]
OutputTypeLink = "https://docs.microsoft.com/previous-versions/office/sharepoint-server/ee537040(v=office.15)")]
[CmdletExample(
Code = @"PS:> Get-PnPSubWebs",
Remarks = "Retrieves all subsites of the current context returning the Id, Url, Title and ServerRelativeUrl of each subsite in the output",
Expand All @@ -28,8 +28,12 @@ namespace PnP.PowerShell.Commands
SortOrder = 3)]
[CmdletExample(
Code = @"PS:> Get-PnPSubWebs -Identity Team1 -Recurse",
Remarks = "Retrieves all subsites of the subsite Team1 and all of its nested child subsites returning the Id, Url, Title and ServerRelativeUrl of each subsite in the output",
Remarks = "Retrieves all subsites of the subsite Team1 and all of its nested child subsites",
SortOrder = 4)]
[CmdletExample(
Code = @"PS:> Get-PnPSubWebs -Identity Team1 -Recurse -IncludeRootWeb",
Remarks = "Retrieves the rootweb, all subsites of the subsite Team1 and all of its nested child subsites",
SortOrder = 5)]
public class GetSubWebs : PnPWebRetrievalsCmdlet<Web>
{
[Parameter(Mandatory = false, ValueFromPipeline = true, Position = 0, HelpMessage = "If provided, only the subsite with the provided Id, GUID or the Web instance will be returned")]
Expand All @@ -38,29 +42,69 @@ public class GetSubWebs : PnPWebRetrievalsCmdlet<Web>
[Parameter(Mandatory = false, HelpMessage = "If provided, recursion through all subsites and their children will take place to return them as well")]
public SwitchParameter Recurse;

[Parameter(Mandatory = false, HelpMessage = "If provided, the results will also contain the rootweb")]
public SwitchParameter IncludeRootWeb;

protected override void ExecuteCmdlet()
{
DefaultRetrievalExpressions = new Expression<Func<Web, object>>[] { w => w.Id, w => w.Url, w => w.Title, w => w.ServerRelativeUrl };

Web parentWeb = SelectedWeb;
List<Web> results = new List<Web>();
if(IncludeRootWeb)
{
parentWeb.EnsureProperties(RetrievalExpressions);
results.Add(parentWeb);
}

if (Identity != null)
{
if (Identity.Id != Guid.Empty)
try
{
parentWeb = parentWeb.GetWebById(Identity.Id);
if (Identity.Id != Guid.Empty)
{
parentWeb = parentWeb.GetWebById(Identity.Id);
}
else if (Identity.Web != null)
{
parentWeb = Identity.Web;
}
else if (Identity.Url != null)
{
parentWeb = parentWeb.GetWebByUrl(Identity.Url);
}
}
else if (Identity.Web != null)
catch(ServerException e) when (e.ServerErrorTypeName.Equals("System.IO.FileNotFoundException"))
{
parentWeb = Identity.Web;
throw new PSArgumentException($"No subweb found with the provided id or url", nameof(Identity));
}
else if (Identity.Url != null)

if (parentWeb != null)
{
parentWeb = parentWeb.GetWebByUrl(Identity.Url);
if (Recurse)
{
results.Add(parentWeb);
results.AddRange(GetSubWebsInternal(parentWeb.Webs, Recurse));
}
else
{
results.Add(parentWeb);
}
}
else
{
throw new PSArgumentException($"No subweb found with the provided id or url", nameof(Identity));
}
}
else
{
ClientContext.Load(parentWeb.Webs);
ClientContext.ExecuteQueryRetry();

results.AddRange(GetSubWebsInternal(parentWeb.Webs, Recurse));
}

var allWebs = GetSubWebsInternal(parentWeb.Webs, Recurse);
WriteObject(allWebs, true);
WriteObject(results, true);
}

private List<Web> GetSubWebsInternal(WebCollection subsites, bool recurse)
Expand Down
Loading

0 comments on commit 5f4fdeb

Please sign in to comment.