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

PnP PowerShell脚本报错:Get-PnPAzureADUser cmdlet未识别求解决

解决 Get-PnPAzureADUser 未被识别的问题

1. 确认cmdlet名称与模块兼容性

PnP PowerShell的旧版模块(SharePointPnPPowerShellOnline)并不包含Get-PnPAzureADUser这个cmdlet。根据你的脚本目标选择对应方案:

  • 若要获取SharePoint站点内的用户/权限:改用 Get-PnPUser
  • 若要获取Azure AD全局用户:要么升级到新版PnP.PowerShell模块,要么使用AzureAD原生模块的Get-AzureADUser

2. 安装/更新新版PnP.PowerShell模块

以管理员身份打开PowerShell,执行以下命令完成模块升级:

# 卸载旧版PnP模块(若已安装)
Uninstall-Module -Name SharePointPnPPowerShellOnline -AllVersions -Force

# 安装最新版PnP.PowerShell
Install-Module -Name PnP.PowerShell -Force -AllowClobber

# 更新到最新版本(确保功能完整)
Update-Module -Name PnP.PowerShell

3. 验证模块与cmdlet

导入模块并检查目标cmdlet是否存在:

Import-Module PnP.PowerShell
Get-Command Get-PnPAzureADUser

如果命令返回该cmdlet的详细信息,说明模块安装成功,重新运行脚本即可。

4. 替代方案:使用AzureAD模块

如果仅需获取Azure AD用户,可直接使用AzureAD原生模块:

# 安装AzureAD模块
Install-Module -Name AzureAD -Force

# 连接到Azure AD
Connect-AzureAD

# 获取用户
Get-AzureADUser

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 18:11:05