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 #2187 from SharePoint/dev
Browse files Browse the repository at this point in the history
August 2018 Release
  • Loading branch information
erwinvanhunen authored Jul 29, 2019
2 parents 199beb0 + 30a37d7 commit 7ea10fa
Show file tree
Hide file tree
Showing 26 changed files with 1,065 additions and 600 deletions.
Binary file modified Binaries/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
515 changes: 343 additions & 172 deletions Binaries/SharePointPnP.Modernization.Framework.xml

Large diffs are not rendered by default.

Binary file modified Binaries/release/SharePointPnP.Modernization.Framework.dll
Binary file not shown.
515 changes: 343 additions & 172 deletions Binaries/release/SharePointPnP.Modernization.Framework.xml

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ 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.12.1908.0]

### Added
- Added -ResetRoleInheritance to Set-PnPList
- Documentation updates
- Added a TemplateId parameter to Apply-PnPProvisioningTemplate to allow to apply a specific template in case multiple templates exist in a single file.

### Changed

- Fixed potential issue when using -CurrentCredentials with Connect-PnPOnline in an on-premises context
- Fixed bug in Set-PnPListItem when using SystemUpdate and setting a content type.
- Grant-PnPTenantServicePrincipalPermission now handles multi-language environments where the Tenant App Catalog is in a different language than English.
- Save-PnPProvisioningTemplate, if saving an instance to a PnP file, will now store referenced files etc in the PnP file.

### Contributors

- Lars Fernhomberg [lafe]
- Chris O'Connor [kachihro]
- Koen Zomers [KoenZomers]
- Gautam Sheth [gautamdsheth]
- Andres Mariano Gorzelany [get-itips]

## [3.11.1907.0]

### Added
Expand All @@ -14,9 +36,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Changed

- ConvertTo-PnPClientSidePage: Added support for specifying a custom URL mapping file (UrlMappingFile parameter)
- Get-PnPField: Return managed metadata fields as TaxonomyField instead of generic Field (#2130)
- Submit-PnPSearchQuery: Added alias Invoke-PnPSearchQuery for semantic aligning the verbs (#2168)
- Copy-PnPFile: Bugfix (#2103 #2148)

### Contributors

- Andi Krüger [andikrueger]

## [3.10.1906.0]

Expand Down
49 changes: 28 additions & 21 deletions Commands/Apps/GrantTenantServicePrincipalPermission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,37 @@ protected override void ExecuteCmdlet()
{
var packageName = $"pnp-temporary-request-{System.Guid.NewGuid()}";
var appCatalog = Tenant.GetAppCatalog();
using (var appCatalogContext = ClientContext.Clone(appCatalog))
if (appCatalog != null)
{
var list = appCatalogContext.Web.Lists.GetByTitle("Web Api Permission Requests");
var itemCI = new ListItemCreationInformation();
var item = list.AddItem(itemCI);
item["_ows_PackageName"] = packageName;
item["_ows_PackageVersion"] = "0.0.0.0";
item["_ows_Scope"] = Scope;
item["_ows_ResourceId"] = Resource;
item.Update();
appCatalogContext.ExecuteQueryRetry();
}
using (var appCatalogContext = ClientContext.Clone(appCatalog))
{
var list = appCatalogContext.Web.GetListByUrl("Lists/WebApiPermissionRequests");
var itemCI = new ListItemCreationInformation();
var item = list.AddItem(itemCI);
item["_ows_PackageName"] = packageName;
item["_ows_PackageVersion"] = "0.0.0.0";
item["_ows_Scope"] = Scope;
item["_ows_ResourceId"] = Resource;
item.Update();
appCatalogContext.ExecuteQueryRetry();
}

var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
var requests = ClientContext.LoadQuery(servicePrincipal.PermissionRequests.Where(r => r.PackageName == packageName));
ClientContext.ExecuteQueryRetry();
if (requests.Any())
{
var newRequest = requests.First();
var request = servicePrincipal.PermissionRequests.GetById(newRequest.Id);
var grant = request.Approve();
ClientContext.Load(grant);
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
var requests = ClientContext.LoadQuery(servicePrincipal.PermissionRequests.Where(r => r.PackageName == packageName));
ClientContext.ExecuteQueryRetry();
WriteObject(new TenantServicePrincipalPermissionGrant(grant));
if (requests.Any())
{
var newRequest = requests.First();
var request = servicePrincipal.PermissionRequests.GetById(newRequest.Id);
var grant = request.Approve();
ClientContext.Load(grant);
ClientContext.ExecuteQueryRetry();
WriteObject(new TenantServicePrincipalPermissionGrant(grant));
}
}
else
{
WriteWarning("Tenant app catalog is not available. You must create the tenant app catalog before executing this command");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ namespace SharePointPnP.PowerShell.Commands.Base
#if !ONPREMISES
#if !NETSTANDARD2_0
[CmdletExample(
Code = "PS:> Connect-PnPOnline -Scopes $arrayOfScopes",
Remarks = "Connects to Azure AD and gets and OAuth 2.0 Access Token to consume the Microsoft Graph API including the declared permission scopes. The available permission scopes are defined at the following URL: https://graph.microsoft.io/en-us/docs/authorization/permission_scopes",
Code = "PS:> Connect-PnPOnline -Scopes \"Mail.Read\",\"Files.Read\"",
Remarks = "Connects to Azure AD and gets and OAuth 2.0 Access Token to consume the Microsoft Graph API including the declared permission scopes. The available permission scopes are defined at the following URL: https://docs.microsoft.com/en-us/graph/permissions-reference",
SortOrder = 13)]
#endif
#endif
Expand Down
6 changes: 6 additions & 0 deletions Commands/Base/SPOnlineConnectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, PSCred
{
context.Credentials = new NetworkCredential(credentials.UserName, credentials.Password);
}
else
{
// If current credentials should be used, use the DefaultNetworkCredentials of the CredentialCache. This has the same effect
// as using "UseDefaultCredentials" in a HttpClient.
context.Credentials = CredentialCache.DefaultNetworkCredentials;
}
}
#if SP2013 || SP2016 || SP2019
var connectionType = ConnectionType.OnPrem;
Expand Down
67 changes: 0 additions & 67 deletions Commands/Base/deprecated/ConnectPnPMicrosoftGraph.deprecated.cs

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion Commands/Branding/AddJavaScriptLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace SharePointPnP.PowerShell.Commands.Branding
{
[Cmdlet(VerbsCommon.Add, "PnPJavaScriptLink")]
[CmdletHelp("Adds a link to a JavaScript file to a web or sitecollection",
[CmdletHelp("Adds a link to a JavaScript file to a web or sitecollection, valid only for SharePoint classic site experience.",
"Creates a custom action that refers to a JavaScript file",
Category = CmdletHelpCategory.Branding)]
[CmdletExample(Code = "PS:> Add-PnPJavaScriptLink -Name jQuery -Url https://code.jquery.com/jquery.min.js -Sequence 9999 -Scope Site",
Expand Down
11 changes: 11 additions & 0 deletions Commands/Fields/GetField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
Expand Down Expand Up @@ -145,6 +146,7 @@ protected override void ExecuteCmdlet()
}
ClientContext.Load(field, RetrievalExpressions);
ClientContext.ExecuteQueryRetry();

switch (field.FieldTypeKind)
{
case FieldType.DateTime:
Expand Down Expand Up @@ -208,6 +210,15 @@ protected override void ExecuteCmdlet()
WriteObject(ClientContext.CastTo<FieldNumber>(field));
break;
}
case FieldType.Invalid:
{
if (field.TypeAsString.StartsWith("TaxonomyFieldType"))
{
WriteObject(ClientContext.CastTo<TaxonomyField>(field));
break;
}
goto default;
}
default:
{
WriteObject(field);
Expand Down
54 changes: 42 additions & 12 deletions Commands/Files/CopyFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,52 @@ protected override void ExecuteCmdlet()
_sourceContext = ClientContext.Clone(sourceWebUri);
}

File file = _sourceContext.Web.GetFileByServerRelativeUrl(SourceUrl);
Folder folder = _sourceContext.Web.GetFolderByServerRelativeUrl(SourceUrl);
file.EnsureProperties(f => f.Name, f => f.Exists);
#if !SP2013
folder.EnsureProperties(f => f.Name, f => f.Exists);
bool srcIsFolder = folder.Exists;
#else
folder.EnsureProperties(f => f.Name);
bool srcIsFolder;
bool isFile = true;
bool srcIsFolder = false;

File file = null;
Folder folder = null;

try
{
folder.EnsureProperties(f => f.ItemCount); //Using ItemCount as marker if this is a file or folder
srcIsFolder = true;
#if ONPREMISES
file = _sourceContext.Web.GetFileByServerRelativeUrl(SourceUrl);
#else
file = _sourceContext.Web.GetFileByServerRelativePath(ResourcePath.FromDecodedUrl(SourceUrl));
#endif
file.EnsureProperties(f => f.Name, f => f.Exists);
}
catch
{
srcIsFolder = false;
isFile = false;
}

if (!isFile)
{
#if ONPREMISES
folder = _sourceContext.Web.GetFolderByServerRelativeUrl(SourceUrl);
#else
folder = _sourceContext.Web.GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(SourceUrl));
#endif

#if !SP2013
folder.EnsureProperties(f => f.Name, f => f.Exists);
srcIsFolder = folder.Exists;
#else
folder.EnsureProperties(f => f.Name);

try
{
folder.EnsureProperties(f => f.ItemCount); //Using ItemCount as marker if this is a file or folder
srcIsFolder = true;
}
catch
{
srcIsFolder = false;
}

#endif
}

if (Force || ShouldContinue(string.Format(Resources.CopyFile0To1, SourceUrl, TargetUrl), Resources.Confirm))
{
Expand All @@ -149,7 +175,11 @@ protected override void ExecuteCmdlet()
{
var targetFile = UrlUtility.Combine(TargetUrl, file.Name);
// If src/dst are on the same Web, then try using CopyTo - backwards compability
#if ONPREMISES
file.CopyTo(targetFile, OverwriteIfAlreadyExists);
#else
file.CopyToUsingPath(ResourcePath.FromDecodedUrl(targetFile), OverwriteIfAlreadyExists);
#endif
_sourceContext.ExecuteQueryRetry();
return;
}
Expand Down
Loading

0 comments on commit 7ea10fa

Please sign in to comment.