You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Where筛选时PowerShell Get-ComplianceSearch的Items与Size值为0

问题原因与解决方法

问题根因

Get-ComplianceSearch不带-Identity参数批量查询时,返回的是简化的摘要对象,仅包含任务名称、状态等基础属性,不会自动加载任务运行后的统计数据(Items、Size这类字段)。只有通过-Identity指定单个任务时,才会从Microsoft Purview后端拉取该任务的完整详情,包括实际的搜索结果统计值。

解决方法

通过循环逐个查询符合条件的任务,来获取完整的Items和Size数据:

# 先筛选出目标任务集合
$targetSearches = Get-ComplianceSearch | Where-Object { $_.Name -like 'Spam Emails*' }

# 循环遍历每个任务,获取完整统计数据
foreach ($search in $targetSearches) {
    Get-ComplianceSearch -Identity $search.Identity | Select-Object Name, Items, Size
}

如果需要导出结果到文件方便查看,可以用下面的脚本:

$results = @()
foreach ($search in $targetSearches) {
    $fullSearch = Get-ComplianceSearch -Identity $search.Identity
    $results += [PSCustomObject]@{
        Name  = $fullSearch.Name
        Items = $fullSearch.Items
        Size  = $fullSearch.Size
    }
}
$results | Export-Csv -Path "SpamSearchResults.csv" -NoTypeInformation

内容的提问来源于stack exchange,提问作者ADY

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 22:07:07