Skip to content

Commit 55da49e

Browse files
authored
Enhance IsCopilotSearchable parameter handling for non-ImageDocumentLibrary types (#5181)
1 parent 9ee6a65 commit 55da49e

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

documentation/Add-PnPOrgAssetsLibrary.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,17 @@ Accept wildcard characters: False
103103
```
104104
105105
### -IsCopilotSearchable
106-
Indicates that the organizational assets library should be searchable in the CoPilot search experience in Office applications to locate corporate images. Only works when the OrgAssetType is set to ImageDocumentLibrary.
106+
Indicates that the organizational assets library should be searchable in the Copilot search experience in Office applications to locate corporate images.
107+
108+
This setting is only supported when `-OrgAssetType` is set to `ImageDocumentLibrary`. When using other `OrgAssetType` values (for example `OfficeTemplateLibrary`), this setting will always be `False` and specifying `-IsCopilotSearchable:$true` will result in an error.
107109

108110
```yaml
109111
Type: Boolean
110112
Parameter Sets: (All)
111113
112114
Required: False
113115
Position: Named
114-
Default value: True
116+
Default value: False
115117
Accept pipeline input: False
116118
Accept wildcard characters: False
117119
```

src/Commands/Admin/AddOrgAssetsLibrary.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,35 @@ public class AddOrgAssetsLibrary : PnPSharePointOnlineAdminCmdlet
2626
public bool DefaultOriginAdded = true;
2727

2828
[Parameter(Mandatory = false)]
29-
public bool IsCopilotSearchable = true;
29+
public bool IsCopilotSearchable = false;
3030

3131
protected override void ExecuteCmdlet()
3232
{
33-
Tenant.AddToOrgAssetsLibWithConfig(CdnType, LibraryUrl, ThumbnailUrl, OrgAssetType, DefaultOriginAdded, new OrgAssetsLibraryConfigParam { IsCopilotSearchable = IsCopilotSearchable});
33+
var config = new OrgAssetsLibraryConfigParam();
34+
35+
// Copilot search is only supported for ImageDocumentLibrary.
36+
// SharePoint has started enforcing this more strictly, so we guard against sending an invalid config.
37+
if (OrgAssetType != OrgAssetType.ImageDocumentLibrary)
38+
{
39+
if (ParameterSpecified(nameof(IsCopilotSearchable)) && IsCopilotSearchable)
40+
{
41+
ThrowTerminatingError(new ErrorRecord(
42+
new PSArgumentException("-IsCopilotSearchable can only be set to $true when -OrgAssetType is ImageDocumentLibrary."),
43+
"IsCopilotSearchableUnsupportedForOrgAssetType",
44+
ErrorCategory.InvalidArgument,
45+
IsCopilotSearchable));
46+
}
47+
48+
config.IsCopilotSearchable = false;
49+
config.IsCopilotSearchablePresent = false;
50+
}
51+
else
52+
{
53+
config.IsCopilotSearchable = IsCopilotSearchable;
54+
config.IsCopilotSearchablePresent = ParameterSpecified(nameof(IsCopilotSearchable));
55+
}
56+
57+
Tenant.AddToOrgAssetsLibWithConfig(CdnType, LibraryUrl, ThumbnailUrl, OrgAssetType, DefaultOriginAdded, config);
3458
AdminContext.ExecuteQueryRetry();
3559
}
3660
}

0 commit comments

Comments
 (0)