Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Added
- Added `Get-PnPPersistedLogin` which lists the tenant url, client id and authentication type of every login registered to use the local token cache, so the cache can be inspected without reading it. [#5463](https://github.com/pnp/powershell/pull/5463)
- Added `-PersistLogin` to the certificate based app only parameter sets of `Connect-PnPOnline`, so a connection made with `-CertificatePath`, `-CertificateBase64Encoded`, `-Thumbprint` or the environment variables can reuse its access token from the local cache. The certificate, tenant and client id are still required on each connection, as neither the certificate nor its password is stored. [#5463](https://github.com/pnp/powershell/pull/5463)
- Added `-CopilotSearchOptOut` to `Set-PnPSearchSettings` and exposed the value through `Get-PnPSearchSettings`; added `-CopilotSearchOptIn` to `Set-PnPTenant` and exposed the value through `Get-PnPTenant`. [#5478](https://github.com/pnp/powershell/pull/5478)

### Changed
- Changed `Connect-PnPOnline` to write verbose message on which stored credential it resolved for the url, as it previously picked one up from the credential manager without saying so. [#5463](https://github.com/pnp/powershell/pull/5463)
Expand Down
12 changes: 9 additions & 3 deletions documentation/Get-PnPSearchSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSearchSettings.h
# Get-PnPSearchSettings

## SYNOPSIS
Retrieves search settings for a site
Retrieves search settings for a site, including whether the site collection has opted out of Copilot Search.

## SYNTAX

Expand All @@ -20,7 +20,7 @@ Get-PnPSearchSettings [-Connection <PnPConnection>]

## DESCRIPTION

Allows to retrieve search settings for a site.
Allows to retrieve search settings for a site. The returned object includes the site collection-level `CopilotSearchOptOut` setting. If the setting is not available yet on the tenant, its value is `$null` and a warning is shown.

## EXAMPLES

Expand All @@ -31,6 +31,13 @@ Get-PnPSearchSettings

Retrieve search settings for the site

### EXAMPLE 2
```powershell
(Get-PnPSearchSettings).CopilotSearchOptOut
```

Returns whether the current site collection has opted out of Copilot Search.

## PARAMETERS

### -Connection
Expand All @@ -52,4 +59,3 @@ Accept wildcard characters: False
## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

9 changes: 8 additions & 1 deletion documentation/Get-PnPTenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Get-PnPTenant [-Verbose] [-Connection <PnPConnection>]

## DESCRIPTION
Returns organization-level site collection properties such as StorageQuota, StorageQuotaAllocated, ResourceQuota,
ResourceQuotaAllocated, and SiteCreationMode. The returned object also includes newer tenant settings and telemetry-backed values when available, such as OneDrive organization sharing link expiration settings, block download configuration, request digest enforcement, notification subscription support, content type sync templates, external sharing restrictions, and file version policy overrides.
ResourceQuotaAllocated, and SiteCreationMode. The returned object also includes newer tenant settings and telemetry-backed values when available, such as the Copilot Search opt-in, OneDrive organization sharing link expiration settings, block download configuration, request digest enforcement, notification subscription support, content type sync templates, external sharing restrictions, and file version policy overrides.

If one or more properties cannot be retrieved, such as when a property is not available yet on the tenant due to a new feature rollout, a warning will be shown. Use -Verbose to see detailed information on properties that could not be retrieved.

Expand Down Expand Up @@ -54,6 +54,13 @@ $tenant | Select-Object OneDriveOrganizationSharingLinkMaxExpirationInDays, OneD

This example inspects OneDrive sharing link expiration settings together with list-based tenant restrictions and version policy overrides.

### EXAMPLE 4
```powershell
(Get-PnPTenant).CopilotSearchOptIn
```

Returns whether the tenant has opted in to Copilot Search.

## PARAMETERS

### -Connection
Expand Down
24 changes: 22 additions & 2 deletions documentation/Set-PnPSearchSettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Sets search settings for a site.
## SYNTAX

```powershell
Set-PnPSearchSettings [-SearchBoxInNavBar <SearchBoxInNavBarType>] [-SearchPageUrl <String>]
Set-PnPSearchSettings [-CopilotSearchOptOut <Boolean>] [-SearchBoxInNavBar <SearchBoxInNavBarType>] [-SearchPageUrl <String>]
[-SearchBoxPlaceholderText <String>] [-SearchScope <SearchScopeType>] [-Scope <SearchSettingsScope>] [-Force]
[-Connection <PnPConnection>]
```
Expand Down Expand Up @@ -75,6 +75,13 @@ Set-PnPSearchSettings -SearchScope Hub

Sets default behavior of the suite bar search box to show hub results instead of site results on an associated hub site.

### EXAMPLE 8
```powershell
Set-PnPSearchSettings -CopilotSearchOptOut $true
```

Opts the current site collection out of Copilot Search. The setting is stored on the site collection regardless of the value of `-Scope`.

## PARAMETERS

### -Connection
Expand All @@ -91,6 +98,20 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -CopilotSearchOptOut
Specifies whether the current site collection is opted out of Copilot Search. The setting is stored on the site collection and requires `ManageWeb` permission.

```yaml
Type: Boolean
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Force
Do not ask for confirmation.

Expand Down Expand Up @@ -181,4 +202,3 @@ Accept wildcard characters: False
## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

22 changes: 22 additions & 0 deletions documentation/Set-PnPTenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Set-PnPTenant [-SpecialCharactersStateInFileFolderNames <SpecialCharactersState>
[-EnableMediaReactions <Boolean>]
[-ResyncContentSecurityPolicyConfigurationEntries]
[-ContentSecurityPolicyEnforcement <Boolean>]
[-CopilotSearchOptIn <Boolean>]
[-DisableSpacesActivation <Boolean>]
[-CoreOrganizationSharingLinkRecommendedExpirationInDays <int>]
[-CoreOrganizationSharingLinkMaxExpirationInDays <int>]
Expand Down Expand Up @@ -271,6 +272,13 @@ Set-PnPTenant -ResyncContentSecurityPolicyConfigurationEntries

This example requests a resync of Content Security Policy trusted script sources for SharePoint Framework solutions in the tenant app catalog and reads back whether the resync request is still pending.

### EXAMPLE 10
```powershell
Set-PnPTenant -CopilotSearchOptIn $true
```

This example opts the tenant in to Copilot Search.

## PARAMETERS

### -AllowDownloadingNonWebViewableFiles
Expand Down Expand Up @@ -552,6 +560,20 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -CopilotSearchOptIn
Specifies whether the tenant is opted in to Copilot Search.

```yaml
Type: Boolean
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DelayContentSecurityPolicyEnforcement
Delays the Content security policy enforcement by 90 days, until June 1, 2026.

Expand Down
8 changes: 8 additions & 0 deletions src/Commands/Admin/SetTenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ public class SetTenant : PnPSharePointOnlineAdminCmdlet
[Parameter(Mandatory = false)]
public bool? ContentSecurityPolicyEnforcement { set; get; }

[Parameter(Mandatory = false)]
public bool? CopilotSearchOptIn { set; get; }

[Parameter(Mandatory = false)]
public bool? DisableSpacesActivation { set; get; }

Expand Down Expand Up @@ -1828,6 +1831,11 @@ protected override void ExecuteCmdlet()
Tenant.ContentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement.Value;
modified = true;
}
if (CopilotSearchOptIn.HasValue)
{
Tenant.CopilotSearchOptIn = CopilotSearchOptIn.Value;
modified = true;
}
if (DisableSpacesActivation.HasValue)
{
Tenant.DisableSpacesActivation = DisableSpacesActivation.Value;
Expand Down
13 changes: 13 additions & 0 deletions src/Commands/Model/SPOTenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ public class SPOTenant

public bool? ContentSecurityPolicyConfigSynced { get; private set; }

[CsomToModelConverter(Skip = true)]
public bool? CopilotSearchOptIn { get; private set; }

public bool? CoreDefaultLinkToExistingAccess { get; private set; }

public string CustomizedExternalSharingServiceUrl { get; private set; }
Expand Down Expand Up @@ -650,6 +653,16 @@ public SPOTenant(Tenant tenant, ClientContext clientContext, BasePSCmdlet cmdlet
cmdlet.LogDebug($"Property ContentTypeSyncSiteTemplatesList not loaded due to error '{e.Message}'");
}

try
{
CopilotSearchOptIn = tenant.EnsureProperty(t => t.CopilotSearchOptIn);
}
catch (Exception e)
{
failedProperties++;
cmdlet.LogDebug($"Property CopilotSearchOptIn not loaded due to error '{e.Message}'");
}

ResyncContentSecurityPolicyConfigurationEntries = ContentSecurityPolicyConfigSynced.HasValue
? !ContentSecurityPolicyConfigSynced.Value
: null;
Expand Down
13 changes: 12 additions & 1 deletion src/Commands/Search/GetSearchSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Management.Automation;
using System;
using System.Management.Automation;
using Microsoft.SharePoint.Client;

namespace PnP.PowerShell.Commands.Search
Expand All @@ -13,8 +14,18 @@ protected override void ExecuteCmdlet()

string siteUrl = ClientContext.Web.GetSiteCollectionSearchCenterUrl();
string webUrl = ClientContext.Web.GetWebSearchCenterUrl(urlOnly: true);
bool? copilotSearchOptOut = null;
try
{
copilotSearchOptOut = ClientContext.Site.EnsureProperty(s => s.CopilotSearchOptOut);
}
catch (Exception ex) when (ex is ServerException or PropertyOrFieldNotInitializedException)
{
LogWarning($"The CopilotSearchOptOut setting could not be retrieved: {ex.Message}");
}

PSObject res = new PSObject();
res.Properties.Add(new PSNoteProperty("CopilotSearchOptOut", copilotSearchOptOut));
res.Properties.Add(new PSNoteProperty("Classic Search Center URL", siteUrl));
res.Properties.Add(new PSNoteProperty("Redirect search URL", webUrl));
res.Properties.Add(new PSNoteProperty("Site Search Scope", ClientContext.Web.SearchScope));
Expand Down
13 changes: 13 additions & 0 deletions src/Commands/Search/SetSearchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class SetSearchSettings : PnPWebCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets)]
public SearchScopeType? SearchScope;

[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets)]
public bool? CopilotSearchOptOut;

[Parameter(Mandatory = false)]
public SearchSettingsScope Scope = SearchSettingsScope.Web;

Expand Down Expand Up @@ -70,6 +73,16 @@ protected override void ExecuteCmdlet()
}
}

if (CopilotSearchOptOut.HasValue)
{
ClientContext.Site.CopilotSearchOptOut = CopilotSearchOptOut.Value;
if (!SearchBoxInNavBar.HasValue && !hasSearchPageUrl && !hasSearchPlaceholderText && !SearchScope.HasValue)
{
ClientContext.ExecuteQueryRetry();
return;
}
}

if (this.Scope == SearchSettingsScope.Site)
{
ClientContext.Site.RootWeb.EnsureProperty(w => w.SearchScope);
Expand Down
Loading