From 3d9514bad16cf91b8b5352b325ce462a55667466 Mon Sep 17 00:00:00 2001 From: reshmee011 Date: Sun, 26 May 2024 16:34:14 +0100 Subject: [PATCH 1/3] Files for rss --- .../Get-PnPTenantRestrictedSearchMode.md | 58 +++++++++++++ .../Set-PnPTenantRestrictedSearchMode.md | 83 +++++++++++++++++++ .../Admin/GetTenantRestrictedSearchMode.cs | 17 ++++ .../Admin/SetTenantRestrictedSearchMode.cs | 18 ++++ 4 files changed, 176 insertions(+) create mode 100644 documentation/Get-PnPTenantRestrictedSearchMode.md create mode 100644 documentation/Set-PnPTenantRestrictedSearchMode.md create mode 100644 src/Commands/Admin/GetTenantRestrictedSearchMode.cs create mode 100644 src/Commands/Admin/SetTenantRestrictedSearchMode.cs diff --git a/documentation/Get-PnPTenantRestrictedSearchMode.md b/documentation/Get-PnPTenantRestrictedSearchMode.md new file mode 100644 index 000000000..220e5e322 --- /dev/null +++ b/documentation/Get-PnPTenantRestrictedSearchMode.md @@ -0,0 +1,58 @@ +--- +Module Name: PnP.PowerShell +title: Get-PnPTenantRestrictedSearchMode +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPTenantRestrictedSearchMode.html +--- + +# Get-PnPTenantRestrictedSearchMode + +## SYNOPSIS + +**Required Permissions** + + * Global Administrator or SharePoint Administrator + +Returns Restricted Search mode. + +## SYNTAX + +```powershell +Get-PnPTenantRestrictedSearchMode [-Connection ] +``` + +## DESCRIPTION + +Returns Restricted Search mode. Restricted SharePoint Search is disabled by default. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +Get-PnPTenantRestrictedSearchMode +``` + +Returns Restricted Search mode. + +## PARAMETERS + +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## RELATED LINKS + +[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) diff --git a/documentation/Set-PnPTenantRestrictedSearchMode.md b/documentation/Set-PnPTenantRestrictedSearchMode.md new file mode 100644 index 000000000..583a8a730 --- /dev/null +++ b/documentation/Set-PnPTenantRestrictedSearchMode.md @@ -0,0 +1,83 @@ +--- +Module Name: PnP.PowerShell +title: Set-PnPTenantRestrictedSearchMode +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Set-PnPTenantRestrictedSearchMode.html +--- + +# Set-PnPTenantRestrictedSearchMode + +## SYNOPSIS + +**Required Permissions** + + * Global Administrator or SharePoint Administrator + +Returns Restricted Search mode. + +## SYNTAX + +```powershell +Set-PnPTenantRestrictedSearchMode -Mode [-Connection ] +``` + +## DESCRIPTION + +Returns Restricted Search mode. Restricted SharePoint Search is disabled by default. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +Set-PnPTenantRestrictedSearchMode -Mode Enabled +``` + +Sets or enables the Restricted Tenant Search mode for the tenant. + +### EXAMPLE 2 + +```powershell +Set-PnPTenantRestrictedSearchMode -Mode Disabled +``` + +Disables the Restricted Tenant Search mode for the tenant. + +## PARAMETERS + +### -Mode + +Sets the mode for the Restricted Tenant Search. + +```yaml +Type: RestrictedSearchMode +Parameter Sets: (All) +Accepted values: Enabled, Disabled + +Required: False +Position: 0 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Connection + +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## RELATED LINKS + +[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) diff --git a/src/Commands/Admin/GetTenantRestrictedSearchMode.cs b/src/Commands/Admin/GetTenantRestrictedSearchMode.cs new file mode 100644 index 000000000..86b7acb57 --- /dev/null +++ b/src/Commands/Admin/GetTenantRestrictedSearchMode.cs @@ -0,0 +1,17 @@ +using Microsoft.Online.SharePoint.TenantAdministration; +using PnP.PowerShell.Commands.Base; +using System.Management.Automation; + +namespace PnP.PowerShell.Commands.Files +{ + [Cmdlet(VerbsCommon.Get, "PnPTenantRestrictedSearchMode")] + public class GetTenantRestrictedSearchMode : PnPAdminCmdlet + { + protected override void ExecuteCmdlet() + { + var results = Tenant.GetSPORestrictedSearchMode(); + AdminContext.ExecuteQuery(); + WriteObject(results, true); + } + } +} diff --git a/src/Commands/Admin/SetTenantRestrictedSearchMode.cs b/src/Commands/Admin/SetTenantRestrictedSearchMode.cs new file mode 100644 index 000000000..2aec25821 --- /dev/null +++ b/src/Commands/Admin/SetTenantRestrictedSearchMode.cs @@ -0,0 +1,18 @@ +using Microsoft.Online.SharePoint.TenantAdministration; +using PnP.PowerShell.Commands.Base; +using System.Management.Automation; + +namespace PnP.PowerShell.Commands.Files +{ + [Cmdlet(VerbsCommon.Set, "PnPTenantRestrictedSearchMode")] + public class SetTenantRestrictedSearchMode : PnPAdminCmdlet + { + [Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true)] + public RestrictedSearchMode mode; + protected override void ExecuteCmdlet() + { + Tenant.SetSPORestrictedSearchMode(mode); + AdminContext.ExecuteQuery(); + } + } +} From f04b6863f36955f49c785ac001e4e7cf04fe29d8 Mon Sep 17 00:00:00 2001 From: reshmee011 Date: Tue, 28 May 2024 20:39:11 +0100 Subject: [PATCH 2/3] update to executequeryretry --- src/Commands/Admin/GetTenantRestrictedSearchMode.cs | 2 +- src/Commands/Admin/SetTenantRestrictedSearchMode.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Admin/GetTenantRestrictedSearchMode.cs b/src/Commands/Admin/GetTenantRestrictedSearchMode.cs index 86b7acb57..9b7c7a2e2 100644 --- a/src/Commands/Admin/GetTenantRestrictedSearchMode.cs +++ b/src/Commands/Admin/GetTenantRestrictedSearchMode.cs @@ -10,7 +10,7 @@ public class GetTenantRestrictedSearchMode : PnPAdminCmdlet protected override void ExecuteCmdlet() { var results = Tenant.GetSPORestrictedSearchMode(); - AdminContext.ExecuteQuery(); + AdminContext.ExecuteQueryRetry(); WriteObject(results, true); } } diff --git a/src/Commands/Admin/SetTenantRestrictedSearchMode.cs b/src/Commands/Admin/SetTenantRestrictedSearchMode.cs index 2aec25821..043dd5dda 100644 --- a/src/Commands/Admin/SetTenantRestrictedSearchMode.cs +++ b/src/Commands/Admin/SetTenantRestrictedSearchMode.cs @@ -12,7 +12,7 @@ public class SetTenantRestrictedSearchMode : PnPAdminCmdlet protected override void ExecuteCmdlet() { Tenant.SetSPORestrictedSearchMode(mode); - AdminContext.ExecuteQuery(); + AdminContext.ExecuteQueryRetry(); } } } From b1d6865b6e61068dc7e6d2178fffa6249b8c8654 Mon Sep 17 00:00:00 2001 From: reshmee011 Date: Tue, 28 May 2024 20:45:21 +0100 Subject: [PATCH 3/3] add client --- src/Commands/Admin/GetTenantRestrictedSearchMode.cs | 1 + src/Commands/Admin/SetTenantRestrictedSearchMode.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Commands/Admin/GetTenantRestrictedSearchMode.cs b/src/Commands/Admin/GetTenantRestrictedSearchMode.cs index 9b7c7a2e2..8e63cf644 100644 --- a/src/Commands/Admin/GetTenantRestrictedSearchMode.cs +++ b/src/Commands/Admin/GetTenantRestrictedSearchMode.cs @@ -1,4 +1,5 @@ using Microsoft.Online.SharePoint.TenantAdministration; +using Microsoft.SharePoint.Client; using PnP.PowerShell.Commands.Base; using System.Management.Automation; diff --git a/src/Commands/Admin/SetTenantRestrictedSearchMode.cs b/src/Commands/Admin/SetTenantRestrictedSearchMode.cs index 043dd5dda..f33ba32db 100644 --- a/src/Commands/Admin/SetTenantRestrictedSearchMode.cs +++ b/src/Commands/Admin/SetTenantRestrictedSearchMode.cs @@ -1,5 +1,6 @@ using Microsoft.Online.SharePoint.TenantAdministration; using PnP.PowerShell.Commands.Base; +using Microsoft.SharePoint.Client; using System.Management.Automation; namespace PnP.PowerShell.Commands.Files