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

Commit 271dc09

Browse files
Merge pull request #1827 from SharePoint/dev
January 2019 Release
2 parents 4f339e6 + 256c87d commit 271dc09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4911
-102
lines changed
Binary file not shown.

Binaries/SharePointPnP.Modernization.Framework.xml

+2,297
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

+2,297
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ 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.5.1901.0]
9+
10+
### Added
11+
- Added Reset-PnPFileVersion cmdlet
12+
13+
### Changed
14+
15+
- Add-PnPClientSidePageSection: Added support for section the section background of a client side page
16+
- Updated file and folder cmdlets to support special characters
17+
18+
### Deprecated
19+
20+
### Contributors
21+
- Eric Skaggs (skaggej)
22+
- Gautam Sheth (gautamdsheth)
23+
824
## [3.4.1812.0]
925

1026
### Added
@@ -455,7 +471,7 @@ jensotto
455471
**2015-09-21**
456472

457473
* Added -Parameters parameter to Apply-SPOProvisioningTemplate. See help for the cmdlet for more info.
458-
* Renamed PageUrl parameter of Webpart cmdlets to ServerRelativePageUrl. Set PageUrl as parameter alias to not break existing scripts.
474+
* Renamed PageUrl parameter of web part cmdlets to ServerRelativePageUrl. Set PageUrl as parameter alias to not break existing scripts.
459475

460476
**2015-09-17**
461477

@@ -484,7 +500,7 @@ jensotto
484500

485501
**2015-08-10**
486502

487-
* Added Get-SPOWebPartXml cmdlet to export webpart XML from a page.
503+
* Added Get-SPOWebPartXml cmdlet to export web part XML from a page.
488504

489505
**2015-08-07**
490506

@@ -595,7 +611,7 @@ still works as before.
595611

596612
**2015-01-07**
597613

598-
* Introduced new Cmdlet: Get-SPOWebPartProperty to return webpart properties
614+
* Introduced new Cmdlet: Get-SPOWebPartProperty to return web part properties
599615
* Updated Set-SPOWebPartProperty cmdlet to support int values
600616

601617
**2015-01-02**

Commands/Base/ConnectOnline.cs

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
using SharePointPnP.PowerShell.CmdletHelpAttributes;
1+
using Microsoft.Identity.Client;
2+
using Microsoft.SharePoint.Client;
3+
using OfficeDevPnP.Core;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
25
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
6+
using SharePointPnP.PowerShell.Commands.Provider;
37
using System;
8+
using System.Diagnostics;
49
using System.IO;
10+
using System.Linq;
511
using System.Management.Automation;
12+
using System.Net;
13+
using System.Reflection;
614
using System.Security;
7-
using System.Linq;
8-
using Microsoft.SharePoint.Client;
9-
using OfficeDevPnP.Core;
10-
using SharePointPnP.PowerShell.Commands.Provider;
1115
using File = System.IO.File;
12-
using System.Net;
13-
using Microsoft.Identity.Client;
1416
#if NETSTANDARD2_0
1517
using System.IdentityModel.Tokens.Jwt;
1618
#endif
1719
#if !ONPREMISES
18-
using Microsoft.SharePoint.Client.CompliancePolicy;
1920
#endif
2021

2122
namespace SharePointPnP.PowerShell.Commands.Base
@@ -141,6 +142,8 @@ public class ConnectOnline : PSCmdlet
141142
private static readonly Uri GraphAADLogin = new Uri("https://login.microsoftonline.com/");
142143
private static readonly string[] GraphDefaultScope = { "https://graph.microsoft.com/.default" };
143144
#endif
145+
146+
144147
#if ONPREMISES
145148
private const string ParameterSet_HIGHTRUST_CERT = "High Trust using a X509Certificate2 object.";
146149
private const string ParameterSet_HIGHTRUST_PFX = "High Trust using a certificate from a PFX file.";
@@ -469,6 +472,12 @@ public class ConnectOnline : PSCmdlet
469472

470473
protected override void ProcessRecord()
471474
{
475+
var latestVersion = SPOnlineConnectionHelper.GetLatestVersion();
476+
if (!string.IsNullOrEmpty(latestVersion))
477+
{
478+
WriteWarning(latestVersion);
479+
}
480+
472481
if (IgnoreSslErrors)
473482
{
474483
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
@@ -756,6 +765,7 @@ private SPOnlineConnection ConnectGraphDeviceLogin(string accessToken)
756765
}
757766
}
758767

768+
759769
private void ConnectGraphAAD()
760770
{
761771
var appCredentials = new ClientCredential(AppSecret);

Commands/Base/PipeBinds/PagePipeBind.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if !ONPREMISES
22
using Microsoft.SharePoint.Client;
3+
using OfficeDevPnP.Core.Utilities;
34
using SharePointPnP.PowerShell.Commands.ClientSidePages;
45
using System;
56
using System.Linq;
@@ -45,9 +46,10 @@ public PagePipeBind(string name)
4546
internal ListItem GetPage(Web web)
4647
{
4748
// Get pages library
48-
ListCollection listCollection = web.Lists;
49-
listCollection.EnsureProperties(coll => coll.Include(li => li.BaseTemplate));
50-
var sitePagesLibrary = listCollection.Where(p => p.BaseTemplate == (int)ListTemplateType.WebPageLibrary).FirstOrDefault();
49+
web.EnsureProperty(w => w.ServerRelativeUrl);
50+
var listServerRelativeUrl = UrlUtility.Combine(web.ServerRelativeUrl, "sitepages");
51+
var sitePagesLibrary = web.GetList(listServerRelativeUrl);
52+
5153
if (sitePagesLibrary != null)
5254
{
5355
CamlQuery query = null;

Commands/Base/SPOnlineConnectionHelper.cs

+37-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using System.Reflection;
1818
using System.Text.RegularExpressions;
1919
using System.Diagnostics;
20-
using System.Runtime.InteropServices;
2120
using System.Net.Http;
2221
using System.Security.Cryptography.X509Certificates;
2322
using Newtonsoft.Json;
@@ -28,6 +27,14 @@ namespace SharePointPnP.PowerShell.Commands.Base
2827
{
2928
internal class SPOnlineConnectionHelper
3029
{
30+
31+
#if DEBUG
32+
private static readonly Uri VersionCheckUrl = new Uri("https://raw.githubusercontent.com/SharePoint/PnP-PowerShell/dev/version.txt");
33+
#else
34+
private static readonly Uri VersionCheckUrl = new Uri("https://raw.githubusercontent.com/SharePoint/PnP-PowerShell/master/version.txt");
35+
#endif
36+
private static bool VersionChecked;
37+
3138
#if !NETSTANDARD2_0
3239
public static AuthenticationContext AuthContext { get; set; }
3340
#endif
@@ -692,5 +699,34 @@ private static bool IsTenantAdminSite(ClientRuntimeContext clientContext)
692699
return (result);
693700
},
694701
true);
702+
703+
public static string GetLatestVersion()
704+
{
705+
try
706+
{
707+
if (!VersionChecked)
708+
{
709+
using (var client = new WebClient())
710+
{
711+
SPOnlineConnectionHelper.VersionChecked = true;
712+
var onlineVersion = client.DownloadString(VersionCheckUrl);
713+
onlineVersion = onlineVersion.Trim(new char[] { '\t', '\r', '\n' });
714+
var assembly = Assembly.GetExecutingAssembly();
715+
var currentVersion = ((AssemblyFileVersionAttribute)assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute))).Version;
716+
if (Version.TryParse(onlineVersion, out Version availableVersion))
717+
{
718+
if (availableVersion > new Version(currentVersion))
719+
{
720+
return $"A newer version of PnP PowerShell is available: {availableVersion}. Consider upgrading.";
721+
}
722+
}
723+
SPOnlineConnectionHelper.VersionChecked = true;
724+
}
725+
}
726+
}
727+
catch
728+
{ }
729+
return null;
730+
}
695731
}
696732
}

Commands/ClientSidePages/AddClientSidePageSection.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
2323
PS> Add-PnPClientSidePageSection -Page $page -SectionTemplate OneColumn",
2424
Remarks = "Adds a new one column section to the Client-Side page 'MyPage'",
2525
SortOrder = 3)]
26+
[CmdletExample(
27+
Code = @"PS:> $page = Add-PnPClientSidePage -Name ""MyPage""
28+
PS> Add-PnPClientSidePageSection -Page $page -SectionTemplate OneColumn -ZoneEmphasis 2",
29+
Remarks = "Adds a new one column section to the Client-Side page 'MyPage' and sets the background to 2 (0 is no background, 3 is highest emphasis)",
30+
SortOrder = 4)]
2631
public class AddClientSidePageSection : PnPWebCmdlet
2732
{
2833
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The name of the page")]
@@ -34,14 +39,17 @@ public class AddClientSidePageSection : PnPWebCmdlet
3439
[Parameter(Mandatory = false, HelpMessage = "Sets the order of the section. (Default = 1)")]
3540
public int Order = 1;
3641

42+
[Parameter(Mandatory = false, HelpMessage = "Sets the background of the section (default = 0)")]
43+
public int ZoneEmphasis = 0;
44+
3745

3846
protected override void ExecuteCmdlet()
3947
{
4048
var clientSidePage = Page?.GetPage(ClientContext);
4149

4250
if (clientSidePage != null)
4351
{
44-
clientSidePage.AddSection(SectionTemplate, Order);
52+
clientSidePage.AddSection(new CanvasSection(clientSidePage, SectionTemplate, Order) { ZoneEmphasis = ZoneEmphasis });
4553
clientSidePage.Save();
4654
}
4755
else

Commands/ClientSidePages/ConvertToClientSidePage.cs

+18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using SharePointPnP.Modernization.Framework.Transform;
77
using SharePointPnP.PowerShell.Commands.Utilities;
88
using System.Reflection;
9+
using SharePointPnP.Modernization.Framework.Cache;
910

1011
namespace SharePointPnP.PowerShell.Commands.ClientSidePages
1112
{
@@ -21,6 +22,10 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
2122
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -WebPartMappingFile c:\contoso\webpartmapping.xml",
2223
Remarks = "Converts a wiki page named 'somepage' to a client side page using a custom provided mapping file",
2324
SortOrder = 2)]
25+
[CmdletExample(
26+
Code = @"PS:> ConvertTo-PnPClientSidePage -Identity ""somepage.aspx"" -Overwrite -AddPageAcceptBanner",
27+
Remarks = "Converts a wiki page named 'somepage' to a client side page and adds the page accept banner web part on top of the page. This requires that the SPFX solution holding the web part (https://github.com/SharePoint/sp-dev-modernization/blob/master/Solutions/PageTransformationUI/assets/sharepointpnp-pagetransformation-client.sppkg?raw=true) has been installed to the tenant app catalog.",
28+
SortOrder = 3)]
2429
public class ConvertToClientSidePage : PnPWebCmdlet
2530
{
2631
private Assembly modernizationAssembly;
@@ -45,6 +50,12 @@ public class ConvertToClientSidePage : PnPWebCmdlet
4550
[Parameter(Mandatory = false, HelpMessage = "Adds the page accept banner web part. The actual web part is specified in webpartmapping.xml file")]
4651
public SwitchParameter AddPageAcceptBanner = false;
4752

53+
[Parameter(Mandatory = false, HelpMessage = "By default the item level permissions on a page are copied to the created client side page. Use this switch to prevent the copy.")]
54+
public SwitchParameter SkipItemLevelPermissionCopyToClientSidePage = false;
55+
56+
[Parameter(Mandatory = false, HelpMessage = "Clears the page component cache. Can be needed if you've installed a new web part to the site and want to use that in a custom webpartmapping file. Restarting your PS session has the same effect.")]
57+
public SwitchParameter ClearPageComponentCache = false;
58+
4859
protected override void ExecuteCmdlet()
4960
{
5061
string tempPath = null;
@@ -93,12 +104,19 @@ protected override void ExecuteCmdlet()
93104
Overwrite = this.Overwrite,
94105
TargetPageTakesSourcePageName = this.TakeSourcePageName,
95106
ReplaceHomePageWithDefaultHomePage = this.ReplaceHomePageWithDefault,
107+
KeepPageSpecificPermissions = !this.SkipItemLevelPermissionCopyToClientSidePage,
96108
ModernizationCenterInformation = new ModernizationCenterInformation()
97109
{
98110
AddPageAcceptBanner = this.AddPageAcceptBanner
99111
},
100112
};
101113

114+
// Clear the client side component cache
115+
if (this.ClearPageComponentCache)
116+
{
117+
CacheManager.Instance.ClearClientSideComponents();
118+
}
119+
102120
string serverRelativeClientPageUrl = pageTransformator.Transform(pti);
103121

104122
ClientSidePagePipeBind cpb = new ClientSidePagePipeBind(System.IO.Path.GetFileName(serverRelativeClientPageUrl));

Commands/ClientSidePages/MoveClientSideComponent.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ public class MoveClientSideWebPart : PnPWebCmdlet
3737
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The instance id of the control. Use Get-PnPClientSideControl retrieve the instance ids.")]
3838
public GuidPipeBind InstanceId;
3939

40-
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTION, HelpMessage = "The section to move the webpart to")]
41-
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTIONCOLUMN, HelpMessage = "The section to move the webpart to")]
40+
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTION, HelpMessage = "The section to move the web part to")]
41+
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTIONCOLUMN, HelpMessage = "The section to move the web part to")]
4242
public int Section;
4343

44-
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_COLUMN, HelpMessage = "The column to move the webpart to")]
45-
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTIONCOLUMN, HelpMessage = "The column to move the webpart to")]
44+
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_COLUMN, HelpMessage = "The column to move the web part to")]
45+
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTIONCOLUMN, HelpMessage = "The column to move the web part to")]
4646
public int Column;
4747

48-
[Parameter(Mandatory = false, ValueFromPipeline = false, ParameterSetName = ParameterSet_COLUMN, HelpMessage = "Change to order of the webpart in the column")]
49-
[Parameter(Mandatory = false, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTION, HelpMessage = "Change to order of the webpart in the column")]
50-
[Parameter(Mandatory = false, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTIONCOLUMN, HelpMessage = "Change to order of the webpart in the column")]
51-
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_POSITION, HelpMessage = "Change to order of the webpart in the column")]
48+
[Parameter(Mandatory = false, ValueFromPipeline = false, ParameterSetName = ParameterSet_COLUMN, HelpMessage = "Change to order of the web part in the column")]
49+
[Parameter(Mandatory = false, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTION, HelpMessage = "Change to order of the web part in the column")]
50+
[Parameter(Mandatory = false, ValueFromPipeline = false, ParameterSetName = ParameterSet_SECTIONCOLUMN, HelpMessage = "Change to order of the web part in the column")]
51+
[Parameter(Mandatory = true, ValueFromPipeline = false, ParameterSetName = ParameterSet_POSITION, HelpMessage = "Change to order of the web part in the column")]
5252
public int Position;
5353

5454
protected override void ExecuteCmdlet()

Commands/ClientSidePages/SetClientSideWebPart.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
1111
[Cmdlet(VerbsCommon.Set, "PnPClientSideWebPart")]
1212
[CmdletHelp("Set Client-Side Web Part properties",
1313
SupportedPlatform = CmdletSupportedPlatform.Online,
14-
DetailedDescription = "Sets specific client side webpart properties. Notice that the title parameter will only set the -internal- title of webpart. The title which is shown in the UI will, if possible, have to be set using the PropertiesJson parameter. Use Get-PnPClientSideComponent to retrieve the instance id and properties of a webpart.",
14+
DetailedDescription = "Sets specific client side web part properties. Notice that the title parameter will only set the -internal- title of web part. The title which is shown in the UI will, if possible, have to be set using the PropertiesJson parameter. Use Get-PnPClientSideComponent to retrieve the instance id and properties of a web part.",
1515
Category = CmdletHelpCategory.WebParts)]
1616
[CmdletExample(
1717
Code = @"PS:> Set-PnPClientSideWebPart -Page Home -Identity a2875399-d6ff-43a0-96da-be6ae5875f82 -PropertiesJson $myproperties",
18-
Remarks = @"Sets the properties of the client side webpart given in the $myproperties variable.", SortOrder = 1)]
18+
Remarks = @"Sets the properties of the client side web part given in the $myproperties variable.", SortOrder = 1)]
1919
public class SetClientSideWebPart : PnPWebCmdlet
2020
{
2121
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The name of the page")]
2222
public ClientSidePagePipeBind Page;
2323

24-
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The identity of the webpart. This can be the webpart instance id or the title of a webpart")]
24+
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The identity of the web part. This can be the web part instance id or the title of a web part")]
2525
public ClientSideWebPartPipeBind Identity;
2626

27-
[Parameter(Mandatory = false, ValueFromPipeline = true, HelpMessage = "Sets the internal title of the webpart. Notice that this will NOT set a visible title.")]
27+
[Parameter(Mandatory = false, ValueFromPipeline = true, HelpMessage = "Sets the internal title of the web part. Notice that this will NOT set a visible title.")]
2828
public string Title;
2929

3030
[Parameter(Mandatory = false, ValueFromPipeline = true, HelpMessage = "Sets the properties as a JSON string.")]
@@ -66,7 +66,7 @@ protected override void ExecuteCmdlet()
6666
}
6767
else
6868
{
69-
throw new Exception($"WebPart does not exist");
69+
throw new Exception($"Web part does not exist");
7070
}
7171
}
7272
}

Commands/Files/AddFile.cs

+4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ protected override void ExecuteCmdlet()
171171
{
172172
try
173173
{
174+
#if ONPREMISES
174175
var existingFile = SelectedWeb.GetFileByServerRelativeUrl(fileUrl);
176+
#else
177+
var existingFile = SelectedWeb.GetFileByServerRelativePath(ResourcePath.FromDecodedUrl(fileUrl));
178+
#endif
175179
existingFile.EnsureProperty(f => f.Exists);
176180
if (existingFile.Exists)
177181
{

Commands/Files/GetFile.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ protected override void ExecuteCmdlet()
111111
});
112112
break;
113113
case URLASFILEOBJECT:
114+
#if ONPREMISES
114115
file = SelectedWeb.GetFileByServerRelativeUrl(serverRelativeUrl);
115-
116+
#else
117+
file = SelectedWeb.GetFileByServerRelativePath(ResourcePath.FromDecodedUrl(serverRelativeUrl));
118+
#endif
116119
ClientContext.Load(file, f => f.Author, f => f.Length,
117120
f => f.ModifiedBy, f => f.Name, f => f.TimeCreated,
118121
f => f.TimeLastModified, f => f.Title);
@@ -122,7 +125,11 @@ protected override void ExecuteCmdlet()
122125
WriteObject(file);
123126
break;
124127
case URLASLISTITEM:
128+
#if ONPREMISES
125129
file = SelectedWeb.GetFileByServerRelativeUrl(serverRelativeUrl);
130+
#else
131+
file = SelectedWeb.GetFileByServerRelativePath(ResourcePath.FromDecodedUrl(serverRelativeUrl));
132+
#endif
126133

127134
ClientContext.Load(file, f => f.Exists, f => f.ListItemAllFields);
128135

Commands/Files/GetFolder.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ protected override void ExecuteCmdlet()
4747
{
4848
Url = UrlUtility.Combine(webServerRelativeUrl, Url);
4949
}
50+
#if ONPREMISES
5051
var folder = SelectedWeb.GetFolderByServerRelativeUrl(Url);
51-
52+
#else
53+
var folder = SelectedWeb.GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(Url));
54+
#endif
5255
folder.EnsureProperties(RetrievalExpressions);
5356

5457
WriteObject(folder);

0 commit comments

Comments
 (0)