This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2649 from NikCharlebois/ODSettings
Added Get/Set-PnPTenantSyncClientRestriction
- Loading branch information
Showing
8 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#if !ONPREMISES | ||
using Microsoft.SharePoint.Client; | ||
using SharePointPnP.PowerShell.CmdletHelpAttributes; | ||
using SharePointPnP.PowerShell.Commands.Base; | ||
using System.Management.Automation; | ||
using SharePointPnP.PowerShell.Commands.Model; | ||
|
||
namespace SharePointPnP.PowerShell.Commands.Admin | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPTenantSyncClientRestriction")] | ||
[CmdletHelp(@"Returns organization-level OneDrive synchronization restriction settings", | ||
DetailedDescription = @"Returns organization-level OneDrive synchronization restriction properties such as BlockMacSync, | ||
OptOutOfGrooveBlock, and TenantRestrictionEnabled. | ||
Currently, there are no parameters for this cmdlet. | ||
You must have the SharePoint Online admin or Global admin role to run the cmdlet.", | ||
SupportedPlatform = CmdletSupportedPlatform.Online, | ||
Category = CmdletHelpCategory.TenantAdmin, | ||
OutputType = typeof(SPOTenantSyncClientRestriction))] | ||
[CmdletExample( | ||
Code = @"PS:> Get-PnPTenantSyncClientRestriction", | ||
Remarks = @"This example returns all tenant OneDrive synchronization restriction settings", SortOrder = 1)] | ||
public class GetPnPTenantSyncClientRestriction : PnPAdminCmdlet | ||
{ | ||
protected override void ExecuteCmdlet() | ||
{ | ||
ClientContext.Load(Tenant); | ||
ClientContext.Load(Tenant, t => t.HideDefaultThemes); | ||
ClientContext.ExecuteQueryRetry(); | ||
WriteObject(new SPOTenantSyncClientRestriction(Tenant)); | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#if !ONPREMISES | ||
using Microsoft.Online.SharePoint.TenantAdministration; | ||
using Microsoft.SharePoint.Client; | ||
using SharePointPnP.PowerShell.CmdletHelpAttributes; | ||
using SharePointPnP.PowerShell.Commands.Base; | ||
using System.Management.Automation; | ||
using System; | ||
using System.Collections.Generic; | ||
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources; | ||
using SharePointPnP.PowerShell.Commands.Model; | ||
|
||
namespace SharePointPnP.PowerShell.Commands.Admin | ||
{ | ||
[Cmdlet(VerbsCommon.Set, "PnPTenantSyncClientRestriction", DefaultParameterSetName = ParameterAttribute.AllParameterSets)] | ||
[CmdletHelp(@"Sets organization-level sync client restriction properties", | ||
DetailedDescription = @"Sets organization-level sync client restriction properties such as BlockMacSync, OptOutOfGroveBlock, and DisableReportProblemDialog. | ||
You must have the SharePoint Online admin or Global admin role to run the cmdlet.", | ||
SupportedPlatform = CmdletSupportedPlatform.Online, | ||
Category = CmdletHelpCategory.TenantAdmin)] | ||
[CmdletExample( | ||
Code = @"PS:> Set-PnPTenantSyncClientRestriction -BlockMacSync:$false", | ||
Remarks = @"This example blocks access to Mac sync clients for OneDrive file synchronization", SortOrder = 1)] | ||
[CmdletExample( | ||
Code = @"PS:> Set-SPOTenantSyncClientRestriction -ExcludedFileExtensions ""pptx;docx;xlsx""", | ||
Remarks = @"This example blocks syncing of PowerPoint, Word, and Excel file types using the new sync client (OneDrive.exe).", SortOrder = 2)] | ||
public class SetTenantSyncClientRestriction : PnPAdminCmdlet | ||
{ | ||
[Parameter(Mandatory = false, HelpMessage = "Block Mac sync clients-- the Beta version and the new sync client (OneDrive.exe). The values for this parameter are $true and $false. The default value is $false.")] | ||
public SwitchParameter BlockMacSync; | ||
|
||
[Parameter(Mandatory = false, HelpMessage = "Specifies if the Report Problem Dialog is disabled or not.")] | ||
public SwitchParameter DisableReportProblemDialog; | ||
|
||
[Parameter(Mandatory = false, HelpMessage = "Sets the domain GUID to add to the safe recipient list. Requires a minimum of 1 domain GUID. The maximum number of domain GUIDs allowed are 125. I.e. 634c71f6-fa83-429c-b77b-0dba3cb70b93,4fbc735f-0ac2-48ba-b035-b1ae3a480887.")] | ||
public List<Guid> DomainGuids; | ||
|
||
[Parameter(Mandatory = false, HelpMessage = "Enables the feature to block sync originating from domains that are not present in the safe recipients list.")] | ||
public SwitchParameter Enable; | ||
|
||
[Parameter(Mandatory = false, HelpMessage = @"Blocks certain file types from syncing with the new sync client (OneDrive.exe). Provide as one string separating the extensions using a semicolon (;). I.e. ""docx;pptx""")] | ||
public List<string> ExcludedFileExtensions; | ||
|
||
[Parameter(Mandatory = false, HelpMessage = "Controls whether or not a tenant's users can sync OneDrive for Business libraries with the old OneDrive for Business sync client. The valid values are OptOut, HardOptin, and SoftOptin.")] | ||
public Enums.GrooveBlockOption GrooveBlockOption; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
ClientContext.Load(Tenant); | ||
ClientContext.ExecuteQueryRetry(); | ||
|
||
if (ParameterSpecified(nameof(DomainGuids))) | ||
{ | ||
Tenant.AllowedDomainListForSyncClient = new List<Guid>(DomainGuids); | ||
} | ||
|
||
Tenant.BlockMacSync = BlockMacSync.ToBool(); | ||
Tenant.IsUnmanagedSyncClientForTenantRestricted = Enable.ToBool(); | ||
Tenant.DisableReportProblemDialog = DisableReportProblemDialog.ToBool(); | ||
|
||
if (ParameterSpecified(nameof(ExcludedFileExtensions))) | ||
{ | ||
Tenant.ExcludedFileExtensionsForSyncClient = ExcludedFileExtensions; | ||
} | ||
|
||
if(ParameterSpecified(nameof(GrooveBlockOption))) | ||
{ | ||
switch (GrooveBlockOption) | ||
{ | ||
case Enums.GrooveBlockOption.OptOut: | ||
Tenant.OptOutOfGrooveBlock = true; | ||
Tenant.OptOutOfGrooveSoftBlock = true; | ||
break; | ||
|
||
case Enums.GrooveBlockOption.HardOptin: | ||
Tenant.OptOutOfGrooveBlock = false; | ||
Tenant.OptOutOfGrooveSoftBlock = true; | ||
break; | ||
|
||
case Enums.GrooveBlockOption.SoftOptin: | ||
Tenant.OptOutOfGrooveBlock = true; | ||
Tenant.OptOutOfGrooveSoftBlock = false; | ||
break; | ||
|
||
default: | ||
throw new PSArgumentException(string.Format(Resources.GrooveBlockOptionNotSupported, nameof(GrooveBlockOption), GrooveBlockOption), nameof(GrooveBlockOption)); | ||
} | ||
} | ||
ClientContext.ExecuteQueryRetry(); | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace SharePointPnP.PowerShell.Commands.Enums | ||
{ | ||
/// <summary> | ||
/// Specifies the options for allowing using the old Groove sync client, used in i.e. <see cref="SetTenantSyncClientRestriction"/>. | ||
/// </summary> | ||
public enum GrooveBlockOption : short | ||
{ | ||
/// <summary> | ||
/// Allows the usage of the old Groove sync client | ||
/// </summary> | ||
OptOut, | ||
|
||
/// <summary> | ||
/// Groove sync client will be blocked and users are asked to upgrade | ||
/// </summary> | ||
HardOptin, | ||
|
||
/// <summary> | ||
/// Groove sync client is still allows but users will be asked to upgrade | ||
/// </summary> | ||
SoftOptin | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#if !ONPREMISES | ||
using Microsoft.Online.SharePoint.TenantAdministration; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace SharePointPnP.PowerShell.Commands.Model | ||
{ | ||
/// <summary> | ||
/// Returned properties for <see cref="GetPnPTenantSyncClientRestriction"/> | ||
/// </summary> | ||
public class SPOTenantSyncClientRestriction | ||
{ | ||
/// <summary> | ||
/// Indication if Mac sync clients, the Beta version and the new sync client (OneDrive.exe), should be blocked | ||
/// </summary> | ||
public bool BlockMacSync { get; private set; } | ||
|
||
/// <summary> | ||
/// The domain GUID to add to the safe recipient list. Requires a minimum of 1 domain GUID to be enabled. The maximum number of domain GUIDs allowed are 125. | ||
/// </summary> | ||
public List<Guid> AllowedDomainList { get; private set; } | ||
|
||
/// <summary> | ||
/// Blocks certain file types from syncing with the new sync client (OneDrive.exe) | ||
/// </summary> | ||
public List<string> ExcludedFileExtensions { get; private set; } | ||
|
||
/// <summary> | ||
/// Indicates if the usage of the old Groove sync client is allowed (true) or not (false) | ||
/// </summary> | ||
public bool OptOutOfGrooveBlock { get; private set; } | ||
|
||
/// <summary> | ||
/// Indicates if the user is asked to upgrade to the new Groove client, but can still use the old client (true) of if the user is forced to upgrade (false) | ||
/// </summary> | ||
public bool OptOutOfGrooveSoftBlock { get; private set; } | ||
|
||
/// <summary> | ||
/// Specifies if the Report Problem Dialog is disabled or not | ||
/// </summary> | ||
public bool DisableReportProblemDialog { get; private set; } | ||
|
||
/// <summary> | ||
/// Indicates if a sync restriction is set on the tenant | ||
/// </summary> | ||
public bool TenantRestrictionEnabled { get; private set; } | ||
|
||
/// <summary> | ||
/// Instantiates a new SPOTenantSyncClientRestriction instance | ||
/// </summary> | ||
/// <param name="tenant">Tenant instance to get the properties from to fill this instance</param> | ||
public SPOTenantSyncClientRestriction(Tenant tenant) | ||
{ | ||
AllowedDomainList = new List<Guid>(tenant.AllowedDomainListForSyncClient); | ||
BlockMacSync = tenant.BlockMacSync; | ||
ExcludedFileExtensions = new List<string>(tenant.ExcludedFileExtensionsForSyncClient); | ||
OptOutOfGrooveBlock = tenant.OptOutOfGrooveBlock; | ||
OptOutOfGrooveSoftBlock = tenant.OptOutOfGrooveSoftBlock; | ||
DisableReportProblemDialog = tenant.DisableReportProblemDialog; | ||
TenantRestrictionEnabled = tenant.IsUnmanagedSyncClientForTenantRestricted; | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters