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

Commit 89b970c

Browse files
Merge pull request #1549 from SharePoint/dev
May 2018 Release
2 parents 054072e + 0c81462 commit 89b970c

39 files changed

+999
-119
lines changed

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,33 @@ 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.26.1805.0] - Unreleased
8+
## [2.26.1805.0]
99
### Added
10+
- Added Enable-PnPPowerShellTelemetry, Disable-PnPPowerShellTelemetry, Get-PnPPowershellTelemetryEnabled
11+
- Added Enable-PnPTenantServicePrincipal
12+
- Added Disable-PnPTenantServicePrincipal
13+
- Added Get-PnPTenantServicePrincipal
14+
- Added Get-PnPTenantServicePermissionRequests
15+
- Added Get-PnPTenantServicePermissionGrants
16+
- Added Approve-PnPTenantServicePrincipalPermissionRequest
17+
- Added Deny-PnPTenantServicePrincipalPermissionRequest
18+
- Added Revoke-PnPTenantServicePrincipalPermission
19+
- Added -Scope parameter to Get-PnPStorageEntity, Set-PnPStorageEntity and Remove-PnPStorageEntity to allow for handling storage entity on site collection scope. This only works on site collections which have a site collection app catalog available.
20+
- Added -CertificatePassword option to New-PnPAzureCertificate
21+
- Added output of thumbprint for New-PnPAzureCertificate and Get-PnPAzureCertificat
1022

1123
### Changed
12-
- Updated Set-PnPTenantSite to handle changing the Site Lock State correctly. You cannot use both -LockState and set other properties at the same time due to possible delays in making the lockstate effective.
24+
- Added -NoTelemetry switch to Connect-PnPOnline
25+
- Updated Connect-PnPOnline to allow for -LoginProviderName when using -UseAdfs to authenticate
26+
- Fixed issue where Add-PnPApp would fail where -Publish parameter was specified and -Scope was set to Site
27+
- Fixed issue where New-PnPUnifiedGroup prompted for creation even though mail alias did not exist
1328

1429
### Deprecated
1530

1631
### Contributors
32+
- Martin Duceb [cebud]
33+
- Kev Maitland [kevmaitland]
34+
- Martin Loitzl [mloitzl]
1735

1836
## [2.25.1804.1]
1937
### Changed

Commands/Admin/GetStorageEntity.cs

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,69 @@
1313
namespace SharePointPnP.PowerShell.Commands
1414
{
1515
[Cmdlet(VerbsCommon.Get, "PnPStorageEntity", SupportsShouldProcess = true)]
16-
[CmdletHelp(@"Retrieve Storage Entities / Farm Properties.",
16+
[CmdletHelp(@"Retrieve Storage Entities / Farm Properties from either the Tenant App Catalog or from the current site if it has a site scope app catalog.",
1717
Category = CmdletHelpCategory.TenantAdmin,
1818
SupportedPlatform = CmdletSupportedPlatform.Online)]
1919
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity", Remarks = "Returns all site storage entities/farm properties", SortOrder = 1)]
2020
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity -Key MyKey", Remarks = "Returns the storage entity/farm property with the given key.", SortOrder = 2)]
21+
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity -Scope Site", Remarks = "Returns all site collection scoped storage entities", SortOrder = 2)]
22+
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity -Key MyKey -Scope Site", Remarks = "Returns the storage entity from the site collection with the given key", SortOrder = 3)]
2123
public class GetPnPStorageEntity : PnPCmdlet
2224
{
2325
[Parameter(Mandatory = false, HelpMessage = "The key of the value to retrieve.")]
2426
public string Key;
2527

26-
protected override void ExecuteCmdlet()
27-
{
28-
var appCatalogUri = ClientContext.Web.GetAppCatalog();
29-
using (var clonedContext = ClientContext.Clone(appCatalogUri))
30-
{
31-
var storageEntitiesIndex = clonedContext.Web.GetPropertyBagValueString("storageentitiesindex", "");
28+
[Parameter(Mandatory = false, HelpMessage = "Defines the scope of the storage entity. Defaults to Tenant.")]
29+
public StorageEntityScope Scope = StorageEntityScope.Tenant;
3230

33-
if (storageEntitiesIndex != "")
31+
protected override void ExecuteCmdlet()
32+
{
33+
string storageEntitiesIndex = string.Empty;
34+
if (Scope == StorageEntityScope.Tenant)
35+
{
36+
var appCatalogUri = ClientContext.Web.GetAppCatalog();
37+
using (var clonedContext = ClientContext.Clone(appCatalogUri))
38+
{
39+
storageEntitiesIndex = clonedContext.Web.GetPropertyBagValueString("storageentitiesindex", "");
40+
}
41+
}
42+
else
43+
{
44+
var appcatalog = ClientContext.Site.RootWeb.SiteCollectionAppCatalog;
45+
ClientContext.Load(appcatalog);
46+
ClientContext.ExecuteQueryRetry();
47+
if (appcatalog.ServerObjectIsNull == false)
48+
{
49+
storageEntitiesIndex = ClientContext.Site.RootWeb.GetPropertyBagValueString("storageentitiesindex", "");
50+
} else
3451
{
35-
var storageEntitiesDict = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(storageEntitiesIndex);
52+
WriteWarning("Site Collection App Catalog is not available on this site.");
53+
}
54+
}
3655

37-
var storageEntities = new List<StorageEntity>();
38-
foreach (var key in storageEntitiesDict.Keys)
39-
{
40-
var storageEntity = new StorageEntity {
41-
Key = key,
42-
Value = storageEntitiesDict[key]["Value"],
43-
Comment = storageEntitiesDict[key]["Comment"],
44-
Description = storageEntitiesDict[key]["Description"]
45-
};
46-
storageEntities.Add(storageEntity);
47-
}
48-
if (MyInvocation.BoundParameters.ContainsKey("Key"))
49-
{
50-
WriteObject(storageEntities.Where(k => k.Key == Key));
51-
}
52-
else
56+
if (!string.IsNullOrEmpty(storageEntitiesIndex))
57+
{
58+
var storageEntitiesDict = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(storageEntitiesIndex);
59+
60+
var storageEntities = new List<StorageEntity>();
61+
foreach (var key in storageEntitiesDict.Keys)
62+
{
63+
var storageEntity = new StorageEntity
5364
{
54-
WriteObject(storageEntities, true);
55-
}
65+
Key = key,
66+
Value = storageEntitiesDict[key]["Value"],
67+
Comment = storageEntitiesDict[key]["Comment"],
68+
Description = storageEntitiesDict[key]["Description"]
69+
};
70+
storageEntities.Add(storageEntity);
71+
}
72+
if (MyInvocation.BoundParameters.ContainsKey("Key"))
73+
{
74+
WriteObject(storageEntities.Where(k => k.Key == Key));
75+
}
76+
else
77+
{
78+
WriteObject(storageEntities, true);
5679
}
5780
}
5881
}

Commands/Admin/RemoveStorageEntity.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,43 @@
1313
namespace SharePointPnP.PowerShell.Commands
1414
{
1515
[Cmdlet(VerbsCommon.Remove, "PnPStorageEntity", SupportsShouldProcess = true)]
16-
[CmdletHelp(@"Remove Storage Entities / Farm Properties.",
16+
[CmdletHelp(@"Remove Storage Entities / Farm Properties from either the tenant scoped app catalog or the current site collection if the site has a site collection scoped app catalog",
1717
Category = CmdletHelpCategory.TenantAdmin,
1818
SupportedPlatform = CmdletSupportedPlatform.Online)]
19-
[CmdletExample(Code = @"PS:> Remove-PnPStorageEntity -Key MyKey ", Remarks = "Removes an existing storage entity / farm property", SortOrder = 1)]
19+
[CmdletExample(Code = @"PS:> Remove-PnPStorageEntity -Key MyKey ", Remarks = "Removes an existing storage entity / farm property", SortOrder = 1)]
20+
[CmdletExample(Code = @"PS:> Remove-PnPStorageEntity -Key MyKey -Scope Site", Remarks = "Removes an existing storage entity from the current site collection", SortOrder = 1)]
2021
public class RemovePnPStorageEntity : PnPCmdlet
2122
{
22-
[Parameter(Mandatory = true, HelpMessage = "The key of the value to set.")]
23+
[Parameter(Mandatory = true, HelpMessage = "The key of the value to remove.")]
2324
public string Key;
2425

26+
[Parameter(Mandatory = false, HelpMessage = "Defines the scope of the storage entity. Defaults to Tenant.")]
27+
public StorageEntityScope Scope = StorageEntityScope.Tenant;
28+
2529
protected override void ExecuteCmdlet()
26-
{
27-
var appCatalogUri = ClientContext.Web.GetAppCatalog();
28-
using (var clonedContext = ClientContext.Clone(appCatalogUri))
30+
{
31+
if (Scope == StorageEntityScope.Tenant)
32+
{
33+
var appCatalogUri = ClientContext.Web.GetAppCatalog();
34+
using (var clonedContext = ClientContext.Clone(appCatalogUri))
35+
{
36+
clonedContext.Web.RemoveStorageEntity(Key);
37+
clonedContext.ExecuteQueryRetry();
38+
}
39+
} else
2940
{
30-
clonedContext.Web.RemoveStorageEntity(Key);
31-
clonedContext.ExecuteQueryRetry();
41+
var appcatalog = ClientContext.Site.RootWeb.SiteCollectionAppCatalog;
42+
ClientContext.Load(appcatalog);
43+
ClientContext.ExecuteQueryRetry();
44+
if (appcatalog.ServerObjectIsNull == false)
45+
{
46+
ClientContext.Site.RootWeb.RemoveStorageEntity(Key);
47+
ClientContext.ExecuteQueryRetry();
48+
}
49+
else
50+
{
51+
WriteWarning("Site Collection App Catalog is not available on this site.");
52+
}
3253
}
3354
}
3455
}

Commands/Admin/SetStorageEntity.cs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
namespace SharePointPnP.PowerShell.Commands
1414
{
1515
[Cmdlet(VerbsCommon.Set, "PnPStorageEntity", SupportsShouldProcess = true)]
16-
[CmdletHelp(@"Set Storage Entities / Farm Properties.",
16+
[CmdletHelp(@"Set Storage Entities / Farm Properties in either the tenant scoped app catalog or the site collection app catalog.",
1717
Category = CmdletHelpCategory.TenantAdmin,
1818
SupportedPlatform = CmdletSupportedPlatform.Online)]
19-
[CmdletExample(Code = @"PS:> Set-PnPStorageEntity -Key MyKey -Value ""MyValue"" -Comment ""My Comment"" -Description ""My Description""", Remarks = "Sets an existing or adds a new storage entity / farm property", SortOrder = 1)]
19+
[CmdletExample(Code = @"PS:> Set-PnPStorageEntity -Key MyKey -Value ""MyValue"" -Comment ""My Comment"" -Description ""My Description""", Remarks = "Sets an existing or adds a new storage entity / farm property at tenant level.", SortOrder = 1)]
20+
[CmdletExample(Code = @"PS:> Set-PnPStorageEntity -Scope Site -Key MyKey -Value ""MyValue"" -Comment ""My Comment"" -Description ""My Description""", Remarks = "Sets an existing or adds a new storage entity site collection level.", SortOrder = 2)]
2021
public class SetPnPStorageEntity : PnPCmdlet
2122
{
2223
[Parameter(Mandatory = true, HelpMessage = "The key of the value to set.")]
@@ -25,19 +26,42 @@ public class SetPnPStorageEntity : PnPCmdlet
2526
[Parameter(Mandatory = true, HelpMessage = "The value to set.")]
2627
public string Value;
2728

28-
[Parameter(Mandatory = true, HelpMessage = "The comment to set.")]
29+
[Parameter(Mandatory = false, HelpMessage = "The comment to set.")]
30+
[AllowNull]
2931
public string Comment;
3032

31-
[Parameter(Mandatory = true, HelpMessage = "The description to set.")]
33+
[Parameter(Mandatory = false, HelpMessage = "The description to set.")]
34+
[AllowNull]
3235
public string Description;
3336

37+
[Parameter(Mandatory = false, HelpMessage = "Defines the scope of the storage entity. Defaults to Tenant.")]
38+
public StorageEntityScope Scope = StorageEntityScope.Tenant;
39+
3440
protected override void ExecuteCmdlet()
35-
{
36-
var appCatalogUri = ClientContext.Web.GetAppCatalog();
37-
using (var clonedContext = ClientContext.Clone(appCatalogUri))
41+
{
42+
if (Scope == StorageEntityScope.Tenant)
43+
{
44+
var appCatalogUri = ClientContext.Web.GetAppCatalog();
45+
using (var clonedContext = ClientContext.Clone(appCatalogUri))
46+
{
47+
clonedContext.Web.SetStorageEntity(Key, Value, Description, Comment);
48+
clonedContext.ExecuteQueryRetry();
49+
}
50+
}
51+
else
3852
{
39-
clonedContext.Web.SetStorageEntity(Key, Value, Description, Comment);
40-
clonedContext.ExecuteQueryRetry();
53+
var appcatalog = ClientContext.Site.RootWeb.SiteCollectionAppCatalog;
54+
ClientContext.Load(appcatalog);
55+
ClientContext.ExecuteQueryRetry();
56+
if (appcatalog.ServerObjectIsNull == false)
57+
{
58+
ClientContext.Site.RootWeb.SetStorageEntity(Key, Value, Description, Comment);
59+
ClientContext.ExecuteQueryRetry();
60+
}
61+
else
62+
{
63+
WriteWarning("Site Collection App Catalog is not available on this site.");
64+
}
4165
}
4266
}
4367
}

Commands/Apps/AddApp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected override void ExecuteCmdlet()
6161

6262
if (Publish)
6363
{
64-
if (manager.Deploy(result, SkipFeatureDeployment))
64+
if (manager.Deploy(result, SkipFeatureDeployment, Scope))
6565
{
6666
result = manager.GetAvailable(result.Id, Scope);
6767
}
@@ -72,10 +72,10 @@ protected override void ExecuteCmdlet()
7272
catch
7373
{
7474
// Exception occurred rolling back
75-
manager.Remove(result);
75+
manager.Remove(result, Scope);
7676
throw;
7777
}
7878
}
7979
}
8080
}
81-
#endif
81+
#endif
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#if !ONPREMISES
2+
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
3+
using Microsoft.SharePoint.Client;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
5+
using SharePointPnP.PowerShell.Commands.Base;
6+
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7+
using SharePointPnP.PowerShell.Commands.Model;
8+
using System.Management.Automation;
9+
10+
namespace SharePointPnP.PowerShell.Commands.Apps
11+
{
12+
[Cmdlet(VerbsLifecycle.Approve, "PnPTenantServicePrincipalPermissionRequest")]
13+
[CmdletHelp(@"Approves a permission request for the current tenant's ""SharePoint Online Client"" service principal",
14+
DetailedDescription = @"Approves a permission request for the current tenant's ""SharePoint Online Client"" service principal
15+
16+
The return value of a successful call is a permission grant object.
17+
18+
To get the collection of permission grants for the ""SharePoint Online Client"" service principal, use the Get-PnPTenantServicePrincipalPermissionGrants command.
19+
20+
Approving a permission request also removes that request from the list of permission requests.",
21+
SupportedPlatform = CmdletSupportedPlatform.Online,
22+
Category = CmdletHelpCategory.TenantAdmin)]
23+
public class ApproveTenantServicePrincipalPermissionRequests : PnPAdminCmdlet
24+
{
25+
[Parameter(Mandatory = true)]
26+
public GuidPipeBind RequestId;
27+
28+
[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
29+
public SwitchParameter Force;
30+
31+
protected override void ExecuteCmdlet()
32+
{
33+
if (Force || ShouldContinue($"Approve request {RequestId.Id}?", "Continue"))
34+
{
35+
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
36+
var request = servicePrincipal.PermissionRequests.GetById(RequestId.Id);
37+
var grant = request.Approve();
38+
ClientContext.Load(grant);
39+
ClientContext.ExecuteQueryRetry();
40+
WriteObject(new TenantServicePrincipalPermissionGrant(grant));
41+
}
42+
}
43+
44+
}
45+
}
46+
#endif
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#if !ONPREMISES
2+
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
3+
using Microsoft.SharePoint.Client;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
5+
using SharePointPnP.PowerShell.Commands.Base;
6+
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7+
using System.Management.Automation;
8+
9+
namespace SharePointPnP.PowerShell.Commands.Apps
10+
{
11+
[Cmdlet(VerbsLifecycle.Deny, "PnPTenantServicePrincipalPermissionRequest")]
12+
[CmdletHelp(@"Denies a permission request for the current tenant's ""SharePoint Online Client"" service principal",
13+
DetailedDescription = @"Denies a permission request for the current tenant's ""SharePoint Online Client"" service principal
14+
15+
Denying a permission request removes that request from the list of permission requests.",
16+
SupportedPlatform = CmdletSupportedPlatform.Online,
17+
Category = CmdletHelpCategory.TenantAdmin)]
18+
public class DenyTenantServicePrincipalPermissionRequests : PnPAdminCmdlet
19+
{
20+
[Parameter(Mandatory = true)]
21+
public GuidPipeBind RequestId;
22+
23+
[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
24+
public SwitchParameter Force;
25+
26+
protected override void ExecuteCmdlet()
27+
{
28+
if (Force || ShouldContinue($"Deny request {RequestId.Id}?", "Continue"))
29+
{
30+
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
31+
var request = servicePrincipal.PermissionRequests.GetById(RequestId.Id);
32+
request.Deny();
33+
ClientContext.ExecuteQueryRetry();
34+
}
35+
}
36+
37+
}
38+
}
39+
#endif
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#if !ONPREMISES
2+
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
3+
using Microsoft.SharePoint.Client;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
5+
using SharePointPnP.PowerShell.Commands.Base;
6+
using System.Management.Automation;
7+
8+
namespace SharePointPnP.PowerShell.Commands.Apps
9+
{
10+
[Cmdlet(VerbsLifecycle.Disable, "PnPTenantServicePrincipal", ConfirmImpact = ConfirmImpact.High)]
11+
[CmdletHelp(@"Enables the current tenant's ""SharePoint Online Client"" service principal.",
12+
DetailedDescription = @"Enables the current tenant's ""SharePoint Online Client"" service principal.",
13+
SupportedPlatform = CmdletSupportedPlatform.Online,
14+
Category = CmdletHelpCategory.TenantAdmin)]
15+
public class DisableTenantServicePrincipal : PnPAdminCmdlet
16+
{
17+
[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
18+
public SwitchParameter Force;
19+
20+
protected override void ExecuteCmdlet()
21+
{
22+
if (ShouldContinue("Do you want to disable the Tenant Service Principal?", "Continue?"))
23+
{
24+
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
25+
servicePrincipal.AccountEnabled = false;
26+
servicePrincipal.Update();
27+
ClientContext.Load(servicePrincipal);
28+
ClientContext.ExecuteQueryRetry();
29+
WriteObject(servicePrincipal);
30+
}
31+
}
32+
}
33+
}
34+
#endif

0 commit comments

Comments
 (0)