使用PowerShell创建自动标签策略时New-AutoSensitivityLabelPolicy未被识别求助
问题:无法识别
New-AutoSensitivityLabelPolicy cmdlet创建自动敏感度标签策略 我尝试用PowerShell为测试SharePoint站点创建新的自动标签策略。登录安全与合规PowerShell后,Get-Label和Get-LabelPolicy cmdlet可正常使用,但New-AutoSensitivityLabelPolicy或New-AutoSensitivityLabelRule始终不被识别。我拥有全局管理员权限,且已在MS Purview中配置安全管理员角色,问题仍存在。
执行的命令序列
Install-Module -Name ExchangeOnlineManagement Import-Module ExchangeOnlineManagement Connect-IPPSSession -UserPrincipalName user@domain.com New-AutoSensitivityLabelPolicy -Name "Confidential auto-labeling policy" -SharePointLocation "Linktosharepointsite.com" -ApplySensitivityLabel "Confidential" -Mode TestWithoutNotifications
报错信息
New-AutoSensitivityLabelPolicy : The term 'New-AutoSensitivityLabelPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
解决方案
- 检查模块版本:
New-AutoSensitivityLabelPolicy要求ExchangeOnlineManagement模块版本≥v3.2.0。执行Get-Module ExchangeOnlineManagement -ListAvailable查看版本,版本过低则用Update-Module -Name ExchangeOnlineManagement -Force更新,更新后重启PowerShell并重连会话。 - 重新导入模块:先卸载现有模块再重装,确保导入完整:
之后用Remove-Module ExchangeOnlineManagement -Force Uninstall-Module -Name ExchangeOnlineManagement -AllVersions -Force Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber Import-Module ExchangeOnlineManagement -ForceGet-Command -Module ExchangeOnlineManagement | Where-Object {$_.Name -like "*AutoSensitivityLabel*"}确认cmdlet是否存在。 - 确认权限角色:创建自动标签策略需要合规管理员或敏感度标签管理员角色,仅全局/安全管理员不够。在MS Purview合规门户的「权限>角色」中,将账号添加到对应角色组,等待1-2小时权限生效后重试。
- 调整PowerShell执行策略:执行
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser确保允许执行模块脚本,避免权限限制导致模块无法加载。 - 升级PowerShell版本:旧版PowerShell可能不兼容新模块,建议升级到PowerShell 7.x后重新操作。
内容的提问来源于stack exchange,提问作者maxdj2k
相关产品推荐
相关产品推荐

