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 #1604 from SharePoint/dev
Browse files Browse the repository at this point in the history
June 2018 Release
  • Loading branch information
erwinvanhunen committed Jun 10, 2018
2 parents f03a9b3 + e9ca5bc commit ff784c8
Show file tree
Hide file tree
Showing 18 changed files with 330 additions and 54 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ 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/).

## [Unreleased]
### Added

### Changed

### Deprecated

### Contributors

## [2.27.1806.0]
### Added
- Added Grant-PnPTenantServicePrincipalPermission to explicitely grant a permission on a resource for the tenant.

### Changed
- Fixed edge cases where progress sent to PowerShell would be null, causing the provisioning of a template to end prematurely.
- Fixed Unregister-PnPHubSite where you could not unregister a hub site if the site was deleted before unregistering

### Deprecated

Expand All @@ -20,6 +32,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added -Timeout option to Add-PnPApp
- Added -CollapseSpecification option to Submit-PnPSearchQuery
- Added -InSiteHierarchy to Get-PnPField to search for fields in the site collection
- Added Get-PnPSearchCrawlLog

### Changed
- Fix for issue where using Add-PnPFile and setting Created and Modified did not update values
Expand Down
2 changes: 1 addition & 1 deletion Commands/Admin/AddTenantCdnOrigin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Code = @"PS:> Add-PnPTenantCdnOrigin -Url /sites/site/subfolder -CdnType Public",
Code = @"PS:> Add-PnPTenantCdnOrigin -OriginUrl /sites/site/subfolder -CdnType Public",
Remarks = @"This example configures a public CDN on site level.", SortOrder = 1)]
public class AddTenantCdnOrigin : PnPAdminCmdlet
{
Expand Down
7 changes: 3 additions & 4 deletions Commands/Admin/GrantHubSiteRights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
namespace SharePointPnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsSecurity.Grant, "PnPHubSiteRights")]
[CmdletHelp(@"Retrieve all or a specific hubsite.",
[CmdletHelp(@"Grant Permissions to associate sites to Hub Sites.",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity", Remarks = "Returns all site storage entities/farm properties", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Key MyKey", Remarks = "Returns the storage entity/farm property with the given key.", SortOrder = 2)]
[CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""myuser@mydomain.com"",""myotheruser@mydomain.com"" -Rights Join", Remarks = "This example shows how to grant right to myuser and myotheruser to associate their sites with hubsite", SortOrder = 1)]
public class GrantHubSiteRights : PnPAdminCmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true)]
Expand All @@ -34,4 +33,4 @@ protected override void ExecuteCmdlet()
}
}
}
#endif
#endif
2 changes: 1 addition & 1 deletion Commands/Admin/RemoveHubSiteAssociation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Code = @"PS:> Remove-PnPHubSiteAssociation -Site https://tenant.sharepoint.com/sites/mysite -HubSite https://tenant.sharepoint.com/sites/hubsite",
Code = @"PS:> Remove-PnPHubSiteAssociation -Site https://tenant.sharepoint.com/sites/mysite",
Remarks = @"This example adds the specified site to the hubsite.", SortOrder = 1)]
public class RemoveHubSiteAssociation : PnPAdminCmdlet
{
Expand Down
11 changes: 8 additions & 3 deletions Commands/Admin/UnregisterHubSite.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#if !ONPREMISES
using System;
using System.Linq;
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;
using OfficeDevPnP.Core.Sites;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System;

namespace SharePointPnP.PowerShell.Commands.Admin
{
Expand All @@ -25,7 +25,12 @@ public class UnregisterHubSite : PnPAdminCmdlet

protected override void ExecuteCmdlet()
{
Tenant.UnregisterHubSite(Site.Url);
var hubSitesProperties = Tenant.GetHubSitesProperties();
ClientContext.Load(hubSitesProperties);
ClientContext.ExecuteQueryRetry();
var hubSite = hubSitesProperties.Single(h => h.SiteUrl.Equals(Site.Url, StringComparison.OrdinalIgnoreCase));

Tenant.UnregisterHubSiteById(hubSite.ID);
ClientContext.ExecuteQueryRetry();
}
}
Expand Down
62 changes: 62 additions & 0 deletions Commands/Apps/GrantTenantServicePrincipalPermission.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.ALM;
using OfficeDevPnP.Core.Enums;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Enums;
using SharePointPnP.PowerShell.Commands.Model;
using System.Linq;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsSecurity.Grant, "PnPTenantServicePrincipalPermission")]
[CmdletHelp(@"Explicitely grants a specified permission to the ""SharePoint Online Client"" service principal",
Category = CmdletHelpCategory.Apps, SupportedPlatform = CmdletSupportedPlatform.Online,
OutputType = typeof(AppMetadata))]
[CmdletExample(
Code = @"PS:> Grant-PnPTenantServicePrincipalPermission -Scope ""Group.Read.All"" -Resource ""Microsoft Graph""",
Remarks = @"This will explicitely grant the Group.Read.All permission on the Microsoft Graph resource", SortOrder = 1)]
public class GrantTenantServicePrincipalPermission : PnPAdminCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The scope to grant the permission for")]
public string Scope;

[Parameter(Mandatory = true, HelpMessage = "The resource to grant the permission for")]
public string Resource;

protected override void ExecuteCmdlet()
{
var packageName = $"pnp-temporary-request-{System.Guid.NewGuid()}";
var appCatalog = Tenant.GetAppCatalog();
using (var appCatalogContext = ClientContext.Clone(appCatalog))
{
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();
}

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);
ClientContext.ExecuteQueryRetry();
WriteObject(new TenantServicePrincipalPermissionGrant(grant));
}
}
}
}
#endif
2 changes: 1 addition & 1 deletion Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public class ConnectOnline : PSCmdlet
#endif
public string AppSecret;

[Parameter(Mandatory = true, ParameterSetName = ParameterSet_WEBLOGIN, HelpMessage = "If you want to connect to SharePoint with browser based login")]
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_WEBLOGIN, HelpMessage = "If you want to connect to SharePoint with browser based login. This is required when you have multi-factor authentication (MFA) enabled.")]
public SwitchParameter UseWebLogin;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_MAIN, HelpMessage = "Specify to use for instance use forms based authentication (FBA)")]
Expand Down
2 changes: 1 addition & 1 deletion Commands/ClientSidePages/GetClientSideComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace SharePointPnP.PowerShell.Commands.ClientSidePages
Code = @"PS:> Get-PnPClientSideComponent -Page Home",
Remarks = @"Returns all controls defined on the given page.", SortOrder = 1)]
[CmdletExample(
Code = @"PS:> Get-PnPClientSideComponent -Page Home -Identity a2875399-d6ff-43a0-96da-be6ae5875f82",
Code = @"PS:> Get-PnPClientSideComponent -Page Home -InstanceId a2875399-d6ff-43a0-96da-be6ae5875f82",
Remarks = @"Returns a specific control defined on the given page.", SortOrder = 2)]
public class GetClientSideControl : PnPWebCmdlet
{
Expand Down
4 changes: 2 additions & 2 deletions Commands/Graph/SetUnifiedGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public class SetUnifiedGroup : PnPGraphCmdlet
[Parameter(Mandatory = false, HelpMessage = "The Description of the group to set.")]
public string Description;

[Parameter(Mandatory = false, HelpMessage = "The array UPN values of owners to add to the group.")]
[Parameter(Mandatory = false, HelpMessage = "The array UPN values of owners to set to the group. Note: Will replace owners.")]
public String[] Owners;

[Parameter(Mandatory = false, HelpMessage = "The array UPN values of members to add to the group.")]
[Parameter(Mandatory = false, HelpMessage = "The array UPN values of members to set to the group. Note: Will replace members.")]
public String[] Members;

[Parameter(Mandatory = false, HelpMessage = "Makes the group private when selected.")]
Expand Down
2 changes: 1 addition & 1 deletion Commands/Lists/RemoveList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class RemoveList : PnPWebCmdlet
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The ID or Title of the list.")]
public ListPipeBind Identity = new ListPipeBind();

[Parameter(Mandatory = false)]
[Parameter(Mandatory = false, HelpMessage = "Defines if the list should be moved to recycle bin or directly deleted.")]
public SwitchParameter Recycle;

[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
Expand Down
4 changes: 2 additions & 2 deletions Commands/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.26.1805.1")]
[assembly: AssemblyFileVersion("2.26.1805.1")]
[assembly: AssemblyVersion("2.27.1806.0")]
[assembly: AssemblyFileVersion("2.27.1806.0")]
[assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")]
56 changes: 31 additions & 25 deletions Commands/Provisioning/ApplyProvisioningTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,15 @@ protected override void ExecuteCmdlet()

applyingInformation.ProgressDelegate = (message, step, total) =>
{
var percentage = Convert.ToInt32((100 / Convert.ToDouble(total)) * Convert.ToDouble(step));
progressRecord.Activity = $"Applying template to {SelectedWeb.Url}";
progressRecord.StatusDescription = message;
progressRecord.PercentComplete = percentage;
progressRecord.RecordType = ProgressRecordType.Processing;
WriteProgress(progressRecord);
if (message != null)
{
var percentage = Convert.ToInt32((100 / Convert.ToDouble(total)) * Convert.ToDouble(step));
progressRecord.Activity = $"Applying template to {SelectedWeb.Url}";
progressRecord.StatusDescription = message;
progressRecord.PercentComplete = percentage;
progressRecord.RecordType = ProgressRecordType.Processing;
WriteProgress(progressRecord);
}
};

var warningsShown = new List<string>();
Expand All @@ -296,19 +299,30 @@ protected override void ExecuteCmdlet()
}
case ProvisioningMessageType.Progress:
{
var activity = message;
if (message.IndexOf("|") > -1)
if (message != null)
{
var messageSplitted = message.Split('|');
if (messageSplitted.Length == 4)
var activity = message;
if (message.IndexOf("|") > -1)
{
var current = double.Parse(messageSplitted[2]);
var total = double.Parse(messageSplitted[3]);
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.Activity = messageSplitted[0];
subProgressRecord.StatusDescription = messageSplitted[1];
subProgressRecord.PercentComplete = Convert.ToInt32((100 / total) * current);
WriteProgress(subProgressRecord);
var messageSplitted = message.Split('|');
if (messageSplitted.Length == 4)
{
var current = double.Parse(messageSplitted[2]);
var total = double.Parse(messageSplitted[3]);
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.Activity = string.IsNullOrEmpty(messageSplitted[0]) ? "-" : messageSplitted[0];
subProgressRecord.StatusDescription = string.IsNullOrEmpty(messageSplitted[1]) ? "-" : messageSplitted[1];
subProgressRecord.PercentComplete = Convert.ToInt32((100 / total) * current);
WriteProgress(subProgressRecord);
}
else
{
subProgressRecord.Activity = "Processing";
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.StatusDescription = activity;
subProgressRecord.PercentComplete = 0;
WriteProgress(subProgressRecord);
}
}
else
{
Expand All @@ -319,14 +333,6 @@ protected override void ExecuteCmdlet()
WriteProgress(subProgressRecord);
}
}
else
{
subProgressRecord.Activity = "Processing";
subProgressRecord.RecordType = ProgressRecordType.Processing;
subProgressRecord.StatusDescription = activity;
subProgressRecord.PercentComplete = 0;
WriteProgress(subProgressRecord);
}
break;
}
case ProvisioningMessageType.Completed:
Expand Down
2 changes: 1 addition & 1 deletion Commands/RecordsManagement/TestListItemIsRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace SharePointPnP.PowerShell.Commands.RecordsManagement
[CmdletHelp("Checks if a list item is a record",
Category = CmdletHelpCategory.RecordsManagement, SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(
Code = @"PS:> Test-PnPListItemAsRecord -List ""Documents"" -Identity 4",
Code = @"PS:> Test-PnPListItemIsRecord -List ""Documents"" -Identity 4",
Remarks = "Returns true if the document in the documents library with id 4 is a record",
SortOrder = 1)]
public class TestListItemIsRecord : PnPWebCmdlet
Expand Down
Loading

0 comments on commit ff784c8

Please sign in to comment.