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

Commit f03a9b3

Browse files
Merge pull request #1570 from SharePoint/dev
May 2018 Intermediate Release 1
2 parents 89b970c + 2d32061 commit f03a9b3

13 files changed

+166
-58
lines changed

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ 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+
## [2.27.1806.0]
9+
### Added
10+
11+
### Changed
12+
13+
### Deprecated
14+
15+
### Contributors
16+
17+
## [2.26.1805.1]
18+
### Added
19+
20+
- Added -Timeout option to Add-PnPApp
21+
- Added -CollapseSpecification option to Submit-PnPSearchQuery
22+
- Added -InSiteHierarchy to Get-PnPField to search for fields in the site collection
23+
24+
### Changed
25+
- Fix for issue where using Add-PnPFile and setting Created and Modified did not update values
26+
827
## [2.26.1805.0]
928
### Added
1029
- Added Enable-PnPPowerShellTelemetry, Disable-PnPPowerShellTelemetry, Get-PnPPowershellTelemetryEnabled

Commands/Apps/AddApp.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class AddApp : PnPCmdlet
4141
[Parameter(Mandatory = false, HelpMessage = "Overwrites the existing app package if it already exists")]
4242
public SwitchParameter Overwrite;
4343

44+
[Parameter(Mandatory = false, HelpMessage = "Specifies the timeout in seconds. Defaults to 200.")]
45+
public int Timeout = 200;
46+
4447
protected override void ExecuteCmdlet()
4548
{
4649
if (!System.IO.Path.IsPathRooted(Path))
@@ -54,7 +57,7 @@ protected override void ExecuteCmdlet()
5457

5558
var manager = new AppManager(ClientContext);
5659

57-
var result = manager.Add(bytes, fileInfo.Name, Overwrite, Scope);
60+
var result = manager.Add(bytes, fileInfo.Name, Overwrite, Scope, timeoutSeconds: Timeout);
5861

5962
try
6063
{

Commands/Base/PnPCmdlet.cs

-5
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,8 @@ protected override void ProcessRecord()
115115
}
116116
catch (Exception ex)
117117
{
118-
if (SPOnlineConnection.CurrentConnection.TelemetryClient != null)
119-
{
120-
SPOnlineConnection.CurrentConnection.TelemetryClient.TrackException(ex);
121-
}
122118
SPOnlineConnection.CurrentConnection.RestoreCachedContext(SPOnlineConnection.CurrentConnection.Url);
123119
WriteError(new ErrorRecord(ex, "EXCEPTION", ErrorCategory.WriteError, null));
124-
SPOnlineConnection.CurrentConnection.TelemetryClient.Flush();
125120
}
126121
}
127122

Commands/Enums/ListItemUpdateType.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace SharePointPnP.PowerShell.Commands.Enums
8+
{
9+
public enum ListItemUpdateType
10+
{
11+
Update,
12+
SystemUpdate,
13+
UpdateOverwriteVersion
14+
}
15+
}

Commands/Fields/GetField.cs

+47-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class GetField : PnPWebRetrievalsCmdlet<Field>
3232
[Parameter(Mandatory = false, HelpMessage = "Filter to the specified group")]
3333
public string Group;
3434

35+
[Parameter(Mandatory = false, ValueFromPipeline = false, HelpMessage = "Search site hierarchy for fields")]
36+
public SwitchParameter InSiteHierarchy;
37+
3538
protected override void ExecuteCmdlet()
3639
{
3740
if (List != null)
@@ -67,8 +70,10 @@ protected override void ExecuteCmdlet()
6770
{
6871
if (!string.IsNullOrEmpty(Group))
6972
{
70-
WriteObject(fieldCollection.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)),true);
71-
} else {
73+
WriteObject(fieldCollection.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)), true);
74+
}
75+
else
76+
{
7277
WriteObject(fieldCollection, true);
7378
}
7479
}
@@ -81,27 +86,62 @@ protected override void ExecuteCmdlet()
8186
{
8287
if (Identity.Id == Guid.Empty && string.IsNullOrEmpty(Identity.Name))
8388
{
84-
ClientContext.Load(SelectedWeb.Fields, fc => fc.IncludeWithDefaultProperties(RetrievalExpressions));
89+
if (InSiteHierarchy.IsPresent)
90+
{
91+
ClientContext.Load(SelectedWeb.AvailableFields, fc => fc.IncludeWithDefaultProperties(RetrievalExpressions));
92+
}
93+
else
94+
{
95+
ClientContext.Load(SelectedWeb.Fields, fc => fc.IncludeWithDefaultProperties(RetrievalExpressions));
96+
}
8597
ClientContext.ExecuteQueryRetry();
8698
if (!string.IsNullOrEmpty(Group))
8799
{
88-
WriteObject(SelectedWeb.Fields.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)), true);
100+
if (InSiteHierarchy.IsPresent)
101+
{
102+
WriteObject(SelectedWeb.AvailableFields.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)).OrderBy(f => f.Title), true);
103+
}
104+
else
105+
{
106+
WriteObject(SelectedWeb.Fields.Where(f => f.Group.Equals(Group, StringComparison.InvariantCultureIgnoreCase)).OrderBy(f => f.Title), true);
107+
}
89108
}
90109
else
91110
{
92-
WriteObject(SelectedWeb.Fields, true);
111+
if (InSiteHierarchy.IsPresent)
112+
{
113+
WriteObject(SelectedWeb.AvailableFields.OrderBy(f => f.Title), true);
114+
}
115+
else
116+
{
117+
WriteObject(SelectedWeb.Fields.OrderBy(f => f.Title), true);
118+
}
93119
}
94120
}
95121
else
96122
{
97123
Field field = null;
98124
if (Identity.Id != Guid.Empty)
99125
{
100-
field = SelectedWeb.Fields.GetById(Identity.Id);
126+
if (InSiteHierarchy.IsPresent)
127+
{
128+
field = SelectedWeb.AvailableFields.GetById(Identity.Id);
129+
}
130+
else
131+
{
132+
field = SelectedWeb.Fields.GetById(Identity.Id);
133+
}
101134
}
102135
else if (!string.IsNullOrEmpty(Identity.Name))
103136
{
104-
field = SelectedWeb.Fields.GetByInternalNameOrTitle(Identity.Name);
137+
if (InSiteHierarchy.IsPresent)
138+
{
139+
field = SelectedWeb.AvailableFields.GetByInternalNameOrTitle(Identity.Name);
140+
}
141+
else
142+
{
143+
field = SelectedWeb.Fields.GetByInternalNameOrTitle(Identity.Name);
144+
}
105145
}
106146
ClientContext.Load(field, RetrievalExpressions);
107147
ClientContext.ExecuteQueryRetry();

Commands/Files/AddFile.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Collections.Generic;
1111
using Microsoft.SharePoint.Client.Taxonomy;
1212
using SharePointPnP.PowerShell.Commands.Utilities;
13+
using SharePointPnP.PowerShell.Commands.Enums;
1314

1415
namespace SharePointPnP.PowerShell.Commands.Files
1516
{
@@ -187,7 +188,7 @@ protected override void ExecuteCmdlet()
187188
{
188189
var item = file.ListItemAllFields;
189190

190-
ListItemHelper.UpdateListItem(item, Values, true,
191+
ListItemHelper.UpdateListItem(item, Values, ListItemUpdateType.UpdateOverwriteVersion,
191192
(warning) =>
192193
{
193194
WriteWarning(warning);
@@ -201,7 +202,11 @@ protected override void ExecuteCmdlet()
201202
{
202203
var item = file.ListItemAllFields;
203204
item["ContentTypeId"] = targetContentType.Id.StringValue;
205+
#if !ONPREMISES
206+
item.UpdateOverwriteVersion();
207+
#else
204208
item.Update();
209+
#endif
205210
ClientContext.ExecuteQueryRetry();
206211
}
207212

@@ -214,7 +219,8 @@ protected override void ExecuteCmdlet()
214219

215220
if (Approve)
216221
SelectedWeb.ApproveFile(fileUrl, ApproveComment);
217-
222+
ClientContext.Load(file);
223+
ClientContext.ExecuteQueryRetry();
218224
WriteObject(file);
219225
}
220226
}

Commands/Lists/AddListItem.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using OfficeDevPnP.Core.Utilities;
99
using SharePointPnP.PowerShell.CmdletHelpAttributes;
1010
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
11+
using SharePointPnP.PowerShell.Commands.Enums;
1112
using SharePointPnP.PowerShell.Commands.Taxonomy;
1213
using SharePointPnP.PowerShell.Commands.Utilities;
1314

@@ -120,7 +121,7 @@ protected override void ExecuteCmdlet()
120121

121122
if (Values != null)
122123
{
123-
item = ListItemHelper.UpdateListItem(item, Values, false,
124+
item = ListItemHelper.UpdateListItem(item, Values, ListItemUpdateType.Update,
124125
(warning) =>
125126
{
126127
WriteWarning(warning);

Commands/Lists/SetListItem.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.SharePoint.Client.Taxonomy;
88
using SharePointPnP.PowerShell.CmdletHelpAttributes;
99
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
10+
using SharePointPnP.PowerShell.Commands.Enums;
1011
using SharePointPnP.PowerShell.Commands.Utilities;
1112
// IMPORTANT: If you make changes to this cmdlet, also make the similar/same changes to the Add-PnPListItem Cmdlet
1213

@@ -108,7 +109,12 @@ protected override void ExecuteCmdlet()
108109
if (Values != null)
109110
{
110111
#if !ONPREMISES
111-
item = ListItemHelper.UpdateListItem(item, Values, SystemUpdate, (warning) =>
112+
var updateType = ListItemUpdateType.Update;
113+
if(SystemUpdate.IsPresent)
114+
{
115+
updateType = ListItemUpdateType.SystemUpdate;
116+
}
117+
item = ListItemHelper.UpdateListItem(item, Values, updateType, (warning) =>
112118
{
113119
WriteWarning(warning);
114120
},
@@ -118,7 +124,7 @@ protected override void ExecuteCmdlet()
118124
}
119125
);
120126
#else
121-
item = ListItemHelper.UpdateListItem(item, Values, false, (warning) =>
127+
item = ListItemHelper.UpdateListItem(item, Values, ListItemUpdateType.Update, (warning) =>
122128
{
123129
WriteWarning(warning);
124130
},

Commands/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
// You can specify all the values or you can default the Build and Revision Numbers
4545
// by using the '*' as shown below:
4646
// [assembly: AssemblyVersion("1.0.*")]
47-
[assembly: AssemblyVersion("2.26.1805.0")]
48-
[assembly: AssemblyFileVersion("2.26.1805.0")]
47+
[assembly: AssemblyVersion("2.26.1805.1")]
48+
[assembly: AssemblyFileVersion("2.26.1805.1")]
4949
[assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")]

Commands/Provisioning/ApplyProvisioningTemplate.cs

+38-31
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Linq;
1212
using OfficeDevPnP.Core.Framework.Provisioning.Providers;
1313
using SharePointPnP.PowerShell.Commands.Components;
14+
using System.Collections.Generic;
1415

1516
namespace SharePointPnP.PowerShell.Commands.Provisioning
1617
{
@@ -119,7 +120,7 @@ protected override void ExecuteCmdlet()
119120
{
120121
Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path);
121122
}
122-
if(!System.IO.File.Exists(Path))
123+
if (!System.IO.File.Exists(Path))
123124
{
124125
throw new FileNotFoundException($"File not found");
125126
}
@@ -278,30 +279,45 @@ protected override void ExecuteCmdlet()
278279
WriteProgress(progressRecord);
279280
};
280281

282+
var warningsShown = new List<string>();
283+
281284
applyingInformation.MessagesDelegate = (message, type) =>
282285
{
283286
switch (type)
284287
{
285288
case ProvisioningMessageType.Warning:
286-
{
287-
WriteWarning(message);
288-
break;
289-
}
289+
{
290+
if (!warningsShown.Contains(message))
291+
{
292+
WriteWarning(message);
293+
warningsShown.Add(message);
294+
}
295+
break;
296+
}
290297
case ProvisioningMessageType.Progress:
291-
{
292-
var activity = message;
293-
if (message.IndexOf("|") > -1)
294298
{
295-
var messageSplitted = message.Split('|');
296-
if (messageSplitted.Length == 4)
299+
var activity = message;
300+
if (message.IndexOf("|") > -1)
297301
{
298-
var current = double.Parse(messageSplitted[2]);
299-
var total = double.Parse(messageSplitted[3]);
300-
subProgressRecord.RecordType = ProgressRecordType.Processing;
301-
subProgressRecord.Activity = messageSplitted[0];
302-
subProgressRecord.StatusDescription = messageSplitted[1];
303-
subProgressRecord.PercentComplete = Convert.ToInt32((100/total)*current);
304-
WriteProgress(subProgressRecord);
302+
var messageSplitted = message.Split('|');
303+
if (messageSplitted.Length == 4)
304+
{
305+
var current = double.Parse(messageSplitted[2]);
306+
var total = double.Parse(messageSplitted[3]);
307+
subProgressRecord.RecordType = ProgressRecordType.Processing;
308+
subProgressRecord.Activity = messageSplitted[0];
309+
subProgressRecord.StatusDescription = messageSplitted[1];
310+
subProgressRecord.PercentComplete = Convert.ToInt32((100 / total) * current);
311+
WriteProgress(subProgressRecord);
312+
}
313+
else
314+
{
315+
subProgressRecord.Activity = "Processing";
316+
subProgressRecord.RecordType = ProgressRecordType.Processing;
317+
subProgressRecord.StatusDescription = activity;
318+
subProgressRecord.PercentComplete = 0;
319+
WriteProgress(subProgressRecord);
320+
}
305321
}
306322
else
307323
{
@@ -311,23 +327,14 @@ protected override void ExecuteCmdlet()
311327
subProgressRecord.PercentComplete = 0;
312328
WriteProgress(subProgressRecord);
313329
}
330+
break;
314331
}
315-
else
316-
{
317-
subProgressRecord.Activity = "Processing";
318-
subProgressRecord.RecordType = ProgressRecordType.Processing;
319-
subProgressRecord.StatusDescription = activity;
320-
subProgressRecord.PercentComplete = 0;
321-
WriteProgress(subProgressRecord);
322-
}
323-
break;
324-
}
325332
case ProvisioningMessageType.Completed:
326-
{
333+
{
327334

328-
WriteProgress(new ProgressRecord(1, message, " ") {RecordType = ProgressRecordType.Completed});
329-
break;
330-
}
335+
WriteProgress(new ProgressRecord(1, message, " ") { RecordType = ProgressRecordType.Completed });
336+
break;
337+
}
331338
}
332339
};
333340

Commands/Search/SubmitSearchQuery.cs

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public class SubmitSearchQuery : PnPWebCmdlet
7474
[Parameter(Mandatory = false, HelpMessage = "Specifies the name of the client which issued the query.", ParameterSetName = ParameterAttribute.AllParameterSets)]
7575
public string ClientType = "ContentSearchLow";
7676

77+
[Parameter(Mandatory = false, HelpMessage = "Limit the number of items per the collapse specification. See https://docs.microsoft.com/en-us/sharepoint/dev/general-development/customizing-search-results-in-sharepoint#collapse-similar-search-results-using-the-collapsespecification-property for more information.", ParameterSetName = ParameterAttribute.AllParameterSets)]
78+
public string CollapseSpecification;
79+
7780
[Parameter(Mandatory = false, HelpMessage = "The keyword query’s hidden constraints.", ParameterSetName = ParameterAttribute.AllParameterSets)]
7881
public string HiddenConstraints;
7982

@@ -217,6 +220,7 @@ private KeywordQuery CreateKeywordQuery()
217220
if (MyInvocation.BoundParameters.ContainsKey("SourceId")) keywordQuery.SourceId = SourceId;
218221
if (MyInvocation.BoundParameters.ContainsKey("ProcessBestBets")) keywordQuery.ProcessBestBets = ProcessBestBets;
219222
if (MyInvocation.BoundParameters.ContainsKey("ProcessPersonalFavorites")) keywordQuery.ProcessPersonalFavorites = ProcessPersonalFavorites;
223+
if (MyInvocation.BoundParameters.ContainsKey("CollapseSpecification")) keywordQuery.CollapseSpecification = CollapseSpecification;
220224

221225
if (SortList != null)
222226
{

Commands/SharePointPnP.PowerShell.Commands.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@
464464
<Compile Include="Base\PipeBinds\SitePipeBind.cs" />
465465
<Compile Include="Base\PipeBinds\TenantSiteScriptPipeBind.cs" />
466466
<Compile Include="Base\PipeBinds\TenantSiteDesignPipeBind.cs" />
467+
<Compile Include="Enums\ListItemUpdateType.cs" />
467468
<Compile Include="Enums\StorageEntityScope.cs" />
468469
<Compile Include="Model\ServicePrincipalPermissionGrant.cs" />
469470
<Compile Include="Navigation\GetNavigationNode.cs" />

0 commit comments

Comments
 (0)