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

Added *-PnPUserOneDriveQuota* commands #2630

Merged
merged 4 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [3.21.2005.0] (not yet released)

### Added
- Added `Set-PnPUserOneDriveQuota`, `Reset-PnPUserOneDriveQuotaToDefault` and `Get-PnPUserOneDriveQuota` commands to work with quotas on OneDrive for Business sites [PR #2630](https://github.com/SharePoint/PnP-PowerShell/pull/2630)

### Changed

### Contributors
- Koen Zomers [koenzomers]

## [3.20.2004.0]

Expand Down
3 changes: 3 additions & 0 deletions Commands/SharePointPnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@
<Compile Include="Site\TestOffice365GroupAliasIsUsed.cs" />
<Compile Include="Taxonomy\NewTermLabel.cs" />
<Compile Include="UserProfiles\GetUPABulkImportStatus.cs" />
<Compile Include="UserProfiles\SetUserOneDriveQuota.cs" />
<Compile Include="UserProfiles\ResetUserOneDriveQuotaToDefault.cs" />
<Compile Include="UserProfiles\GetUserOneDriveQuota.cs" />
<Compile Include="UserProfiles\NewUPABulkImportJob.cs" />
<Compile Include="Utilities\AzureAuthHelper.cs" />
<Compile Include="Utilities\BrowserHelper.cs" />
Expand Down
32 changes: 32 additions & 0 deletions Commands/UserProfiles/GetUserOneDriveQuota.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if !ONPREMISES
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;

namespace SharePointPnP.PowerShell.Commands.UserProfiles
{
[Cmdlet(VerbsCommon.Get, "PnPUserOneDriveQuota")]
[CmdletHelp(@"Retrieves the current quota set on the OneDrive for Business site for a specific user",
DetailedDescription = "This command allows you to request the quota set on the OneDrive for Business site of a specific user. You must connect to the tenant admin website (https://:<tenant>-admin.sharepoint.com) with Connect-PnPOnline in order to use this cmdlet.",
Category = CmdletHelpCategory.UserProfiles)]
[CmdletExample(
Code = @"PS:> Get-PnPUserOneDriveQuota -Account 'user@domain.com'",
Remarks = "Returns the quota set on the OneDrive for Business site for the specified user",
SortOrder = 1)]
public class GetUserOneDriveQuota : PnPAdminCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The account of the user, formatted either as a login name, or as a claims identity, e.g. i:0#.f|membership|user@domain.com", Position = 0)]
public string Account;

protected override void ExecuteCmdlet()
{
var peopleManager = new PeopleManager(ClientContext);
var oneDriveQuota = peopleManager.GetUserOneDriveQuotaMax(Account);
ClientContext.ExecuteQueryRetry();
WriteObject(oneDriveQuota);
}
}
}
#endif
32 changes: 32 additions & 0 deletions Commands/UserProfiles/ResetUserOneDriveQuotaToDefault.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if !ONPREMISES
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;

namespace SharePointPnP.PowerShell.Commands.UserProfiles
{
[Cmdlet(VerbsCommon.Reset, "PnPUserOneDriveQuotaToDefault")]
[CmdletHelp(@"Resets the current quota set on the OneDrive for Business site for a specific user to the tenant default",
DetailedDescription = "This command allows you to reset the quota set on the OneDrive for Business site of a specific user to the default as set on the tenant. You must connect to the tenant admin website (https://:<tenant>-admin.sharepoint.com) with Connect-PnPOnline in order to use this cmdlet.",
Category = CmdletHelpCategory.UserProfiles)]
[CmdletExample(
Code = @"PS:> Reset-PnPUserOneDriveQuotaToDefault -Account 'user@domain.com'",
Remarks = "Resets the quota set on the OneDrive for Business site for the specified user to the tenant default",
SortOrder = 1)]
public class ResetUserOneDriveQuotaMax : PnPAdminCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The account of the user, formatted either as a login name, or as a claims identity, e.g. i:0#.f|membership|user@domain.com", Position = 0)]
public string Account;

protected override void ExecuteCmdlet()
{
var peopleManager = new PeopleManager(ClientContext);
var result = peopleManager.ResetUserOneDriveQuotaToDefault(Account);
ClientContext.ExecuteQueryRetry();
WriteObject(result);
}
}
}
#endif
38 changes: 38 additions & 0 deletions Commands/UserProfiles/SetUserOneDriveQuota.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#if !ONPREMISES
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.UserProfiles;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;

namespace SharePointPnP.PowerShell.Commands.UserProfiles
{
[Cmdlet(VerbsCommon.Set, "PnPUserOneDriveQuota")]
[CmdletHelp(@"Sets the quota on the OneDrive for Business site for a specific user",
DetailedDescription = "This command allows you to set the quota on the OneDrive for Business site of a specific user. You must connect to the tenant admin website (https://:<tenant>-admin.sharepoint.com) with Connect-PnPOnline in order to use this cmdlet.",
Category = CmdletHelpCategory.UserProfiles)]
[CmdletExample(
Code = @"PS:> Set-PnPUserOneDriveQuota -Account 'user@domain.com' -Quota 5368709120 -QuotaWarning 4831838208",
Remarks = "Sets the quota on the OneDrive for Business site for the specified user to 5GB (5368709120 bytes) and sets a warning to be shown at 4.5 GB (4831838208)",
SortOrder = 1)]
public class SetUserOneDriveQuota : PnPAdminCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "The account of the user, formatted either as a login name, or as a claims identity, e.g. i:0#.f|membership|user@domain.com", Position = 0)]
public string Account;

[Parameter(Mandatory = true, HelpMessage = "The quota to set on the OneDrive for Business site of the user, in bytes", Position = 1)]
public long Quota;

[Parameter(Mandatory = true, HelpMessage = "The quota to set on the OneDrive for Business site of the user when to start showing warnings about the drive nearing being full, in bytes", Position = 2)]
public long QuotaWarning;

protected override void ExecuteCmdlet()
{
var peopleManager = new PeopleManager(ClientContext);
var oneDriveQuota = peopleManager.SetUserOneDriveQuota(Account, Quota, QuotaWarning);
ClientContext.ExecuteQueryRetry();
WriteObject(oneDriveQuota);
}
}
}
#endif