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 #1549 from SharePoint/dev
Browse files Browse the repository at this point in the history
May 2018 Release
  • Loading branch information
erwinvanhunen authored May 4, 2018
2 parents 054072e + 0c81462 commit 89b970c
Show file tree
Hide file tree
Showing 39 changed files with 999 additions and 119 deletions.
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,33 @@ 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/).

## [2.26.1805.0] - Unreleased
## [2.26.1805.0]
### Added
- Added Enable-PnPPowerShellTelemetry, Disable-PnPPowerShellTelemetry, Get-PnPPowershellTelemetryEnabled
- Added Enable-PnPTenantServicePrincipal
- Added Disable-PnPTenantServicePrincipal
- Added Get-PnPTenantServicePrincipal
- Added Get-PnPTenantServicePermissionRequests
- Added Get-PnPTenantServicePermissionGrants
- Added Approve-PnPTenantServicePrincipalPermissionRequest
- Added Deny-PnPTenantServicePrincipalPermissionRequest
- Added Revoke-PnPTenantServicePrincipalPermission
- 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.
- Added -CertificatePassword option to New-PnPAzureCertificate
- Added output of thumbprint for New-PnPAzureCertificate and Get-PnPAzureCertificat

### Changed
- 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.
- Added -NoTelemetry switch to Connect-PnPOnline
- Updated Connect-PnPOnline to allow for -LoginProviderName when using -UseAdfs to authenticate
- Fixed issue where Add-PnPApp would fail where -Publish parameter was specified and -Scope was set to Site
- Fixed issue where New-PnPUnifiedGroup prompted for creation even though mail alias did not exist

### Deprecated

### Contributors
- Martin Duceb [cebud]
- Kev Maitland [kevmaitland]
- Martin Loitzl [mloitzl]

## [2.25.1804.1]
### Changed
Expand Down
77 changes: 50 additions & 27 deletions Commands/Admin/GetStorageEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,69 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Get, "PnPStorageEntity", SupportsShouldProcess = true)]
[CmdletHelp(@"Retrieve Storage Entities / Farm Properties.",
[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.",
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-PnPStorageEntity -Key MyKey", Remarks = "Returns the storage entity/farm property with the given key.", SortOrder = 2)]
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity -Scope Site", Remarks = "Returns all site collection scoped storage entities", SortOrder = 2)]
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity -Key MyKey -Scope Site", Remarks = "Returns the storage entity from the site collection with the given key", SortOrder = 3)]
public class GetPnPStorageEntity : PnPCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "The key of the value to retrieve.")]
public string Key;

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

if (storageEntitiesIndex != "")
protected override void ExecuteCmdlet()
{
string storageEntitiesIndex = string.Empty;
if (Scope == StorageEntityScope.Tenant)
{
var appCatalogUri = ClientContext.Web.GetAppCatalog();
using (var clonedContext = ClientContext.Clone(appCatalogUri))
{
storageEntitiesIndex = clonedContext.Web.GetPropertyBagValueString("storageentitiesindex", "");
}
}
else
{
var appcatalog = ClientContext.Site.RootWeb.SiteCollectionAppCatalog;
ClientContext.Load(appcatalog);
ClientContext.ExecuteQueryRetry();
if (appcatalog.ServerObjectIsNull == false)
{
storageEntitiesIndex = ClientContext.Site.RootWeb.GetPropertyBagValueString("storageentitiesindex", "");
} else
{
var storageEntitiesDict = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(storageEntitiesIndex);
WriteWarning("Site Collection App Catalog is not available on this site.");
}
}

var storageEntities = new List<StorageEntity>();
foreach (var key in storageEntitiesDict.Keys)
{
var storageEntity = new StorageEntity {
Key = key,
Value = storageEntitiesDict[key]["Value"],
Comment = storageEntitiesDict[key]["Comment"],
Description = storageEntitiesDict[key]["Description"]
};
storageEntities.Add(storageEntity);
}
if (MyInvocation.BoundParameters.ContainsKey("Key"))
{
WriteObject(storageEntities.Where(k => k.Key == Key));
}
else
if (!string.IsNullOrEmpty(storageEntitiesIndex))
{
var storageEntitiesDict = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(storageEntitiesIndex);

var storageEntities = new List<StorageEntity>();
foreach (var key in storageEntitiesDict.Keys)
{
var storageEntity = new StorageEntity
{
WriteObject(storageEntities, true);
}
Key = key,
Value = storageEntitiesDict[key]["Value"],
Comment = storageEntitiesDict[key]["Comment"],
Description = storageEntitiesDict[key]["Description"]
};
storageEntities.Add(storageEntity);
}
if (MyInvocation.BoundParameters.ContainsKey("Key"))
{
WriteObject(storageEntities.Where(k => k.Key == Key));
}
else
{
WriteObject(storageEntities, true);
}
}
}
Expand Down
37 changes: 29 additions & 8 deletions Commands/Admin/RemoveStorageEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,43 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Remove, "PnPStorageEntity", SupportsShouldProcess = true)]
[CmdletHelp(@"Remove Storage Entities / Farm Properties.",
[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",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[CmdletExample(Code = @"PS:> Remove-PnPStorageEntity -Key MyKey ", Remarks = "Removes an existing storage entity / farm property", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Remove-PnPStorageEntity -Key MyKey ", Remarks = "Removes an existing storage entity / farm property", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Remove-PnPStorageEntity -Key MyKey -Scope Site", Remarks = "Removes an existing storage entity from the current site collection", SortOrder = 1)]
public class RemovePnPStorageEntity : PnPCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The key of the value to set.")]
[Parameter(Mandatory = true, HelpMessage = "The key of the value to remove.")]
public string Key;

[Parameter(Mandatory = false, HelpMessage = "Defines the scope of the storage entity. Defaults to Tenant.")]
public StorageEntityScope Scope = StorageEntityScope.Tenant;

protected override void ExecuteCmdlet()
{
var appCatalogUri = ClientContext.Web.GetAppCatalog();
using (var clonedContext = ClientContext.Clone(appCatalogUri))
{
if (Scope == StorageEntityScope.Tenant)
{
var appCatalogUri = ClientContext.Web.GetAppCatalog();
using (var clonedContext = ClientContext.Clone(appCatalogUri))
{
clonedContext.Web.RemoveStorageEntity(Key);
clonedContext.ExecuteQueryRetry();
}
} else
{
clonedContext.Web.RemoveStorageEntity(Key);
clonedContext.ExecuteQueryRetry();
var appcatalog = ClientContext.Site.RootWeb.SiteCollectionAppCatalog;
ClientContext.Load(appcatalog);
ClientContext.ExecuteQueryRetry();
if (appcatalog.ServerObjectIsNull == false)
{
ClientContext.Site.RootWeb.RemoveStorageEntity(Key);
ClientContext.ExecuteQueryRetry();
}
else
{
WriteWarning("Site Collection App Catalog is not available on this site.");
}
}
}
}
Expand Down
42 changes: 33 additions & 9 deletions Commands/Admin/SetStorageEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Set, "PnPStorageEntity", SupportsShouldProcess = true)]
[CmdletHelp(@"Set Storage Entities / Farm Properties.",
[CmdletHelp(@"Set Storage Entities / Farm Properties in either the tenant scoped app catalog or the site collection app catalog.",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online)]
[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)]
[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)]
[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)]
public class SetPnPStorageEntity : PnPCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The key of the value to set.")]
Expand All @@ -25,19 +26,42 @@ public class SetPnPStorageEntity : PnPCmdlet
[Parameter(Mandatory = true, HelpMessage = "The value to set.")]
public string Value;

[Parameter(Mandatory = true, HelpMessage = "The comment to set.")]
[Parameter(Mandatory = false, HelpMessage = "The comment to set.")]
[AllowNull]
public string Comment;

[Parameter(Mandatory = true, HelpMessage = "The description to set.")]
[Parameter(Mandatory = false, HelpMessage = "The description to set.")]
[AllowNull]
public string Description;

[Parameter(Mandatory = false, HelpMessage = "Defines the scope of the storage entity. Defaults to Tenant.")]
public StorageEntityScope Scope = StorageEntityScope.Tenant;

protected override void ExecuteCmdlet()
{
var appCatalogUri = ClientContext.Web.GetAppCatalog();
using (var clonedContext = ClientContext.Clone(appCatalogUri))
{
if (Scope == StorageEntityScope.Tenant)
{
var appCatalogUri = ClientContext.Web.GetAppCatalog();
using (var clonedContext = ClientContext.Clone(appCatalogUri))
{
clonedContext.Web.SetStorageEntity(Key, Value, Description, Comment);
clonedContext.ExecuteQueryRetry();
}
}
else
{
clonedContext.Web.SetStorageEntity(Key, Value, Description, Comment);
clonedContext.ExecuteQueryRetry();
var appcatalog = ClientContext.Site.RootWeb.SiteCollectionAppCatalog;
ClientContext.Load(appcatalog);
ClientContext.ExecuteQueryRetry();
if (appcatalog.ServerObjectIsNull == false)
{
ClientContext.Site.RootWeb.SetStorageEntity(Key, Value, Description, Comment);
ClientContext.ExecuteQueryRetry();
}
else
{
WriteWarning("Site Collection App Catalog is not available on this site.");
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Commands/Apps/AddApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected override void ExecuteCmdlet()

if (Publish)
{
if (manager.Deploy(result, SkipFeatureDeployment))
if (manager.Deploy(result, SkipFeatureDeployment, Scope))
{
result = manager.GetAvailable(result.Id, Scope);
}
Expand All @@ -72,10 +72,10 @@ protected override void ExecuteCmdlet()
catch
{
// Exception occurred rolling back
manager.Remove(result);
manager.Remove(result, Scope);
throw;
}
}
}
}
#endif
#endif
46 changes: 46 additions & 0 deletions Commands/Apps/ApproveTenantServicePrincipalPermissionRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using SharePointPnP.PowerShell.Commands.Model;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsLifecycle.Approve, "PnPTenantServicePrincipalPermissionRequest")]
[CmdletHelp(@"Approves a permission request for the current tenant's ""SharePoint Online Client"" service principal",
DetailedDescription = @"Approves a permission request for the current tenant's ""SharePoint Online Client"" service principal
The return value of a successful call is a permission grant object.
To get the collection of permission grants for the ""SharePoint Online Client"" service principal, use the Get-PnPTenantServicePrincipalPermissionGrants command.
Approving a permission request also removes that request from the list of permission requests.",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
public class ApproveTenantServicePrincipalPermissionRequests : PnPAdminCmdlet
{
[Parameter(Mandatory = true)]
public GuidPipeBind RequestId;

[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
public SwitchParameter Force;

protected override void ExecuteCmdlet()
{
if (Force || ShouldContinue($"Approve request {RequestId.Id}?", "Continue"))
{
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
var request = servicePrincipal.PermissionRequests.GetById(RequestId.Id);
var grant = request.Approve();
ClientContext.Load(grant);
ClientContext.ExecuteQueryRetry();
WriteObject(new TenantServicePrincipalPermissionGrant(grant));
}
}

}
}
#endif
39 changes: 39 additions & 0 deletions Commands/Apps/DenyTenantServicePrincipalPermissionRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsLifecycle.Deny, "PnPTenantServicePrincipalPermissionRequest")]
[CmdletHelp(@"Denies a permission request for the current tenant's ""SharePoint Online Client"" service principal",
DetailedDescription = @"Denies a permission request for the current tenant's ""SharePoint Online Client"" service principal
Denying a permission request removes that request from the list of permission requests.",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
public class DenyTenantServicePrincipalPermissionRequests : PnPAdminCmdlet
{
[Parameter(Mandatory = true)]
public GuidPipeBind RequestId;

[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
public SwitchParameter Force;

protected override void ExecuteCmdlet()
{
if (Force || ShouldContinue($"Deny request {RequestId.Id}?", "Continue"))
{
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
var request = servicePrincipal.PermissionRequests.GetById(RequestId.Id);
request.Deny();
ClientContext.ExecuteQueryRetry();
}
}

}
}
#endif
34 changes: 34 additions & 0 deletions Commands/Apps/DisableTenantServicePrincipal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#if !ONPREMISES
using Microsoft.Online.SharePoint.TenantAdministration.Internal;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using System.Management.Automation;

namespace SharePointPnP.PowerShell.Commands.Apps
{
[Cmdlet(VerbsLifecycle.Disable, "PnPTenantServicePrincipal", ConfirmImpact = ConfirmImpact.High)]
[CmdletHelp(@"Enables the current tenant's ""SharePoint Online Client"" service principal.",
DetailedDescription = @"Enables the current tenant's ""SharePoint Online Client"" service principal.",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
public class DisableTenantServicePrincipal : PnPAdminCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")]
public SwitchParameter Force;

protected override void ExecuteCmdlet()
{
if (ShouldContinue("Do you want to disable the Tenant Service Principal?", "Continue?"))
{
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext);
servicePrincipal.AccountEnabled = false;
servicePrincipal.Update();
ClientContext.Load(servicePrincipal);
ClientContext.ExecuteQueryRetry();
WriteObject(servicePrincipal);
}
}
}
}
#endif
Loading

0 comments on commit 89b970c

Please sign in to comment.