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

如何用PowerShell获取Azure用户的‘On-premises last sync date time’属性

获取Azure AD用户本地最后同步时间的PowerShell方法

方法1:使用AzureAD模块操作

  • 未安装模块的话先安装:Install-Module -Name AzureAD -Force -AllowClobber
  • 连接到Azure AD:Connect-AzureAD
  • 查询单个用户的同步时间:Get-AzureADUser -Filter "UserPrincipalName eq 'user@domain.com'" | Select-Object DisplayName, UserPrincipalName, OnPremisesLastSyncDateTime
  • 批量查询所有同步用户:Get-AzureADUser -All $true | Where-Object { $_.OnPremisesSyncEnabled -eq $true } | Select-Object DisplayName, UserPrincipalName, OnPremisesLastSyncDateTime

方法2:使用Microsoft Graph PowerShell模块操作

  • 未安装模块的话先安装:Install-Module -Name Microsoft.Graph -Force -AllowClobber
  • 连接到Graph(需要User.Read.All或Directory.Read.All权限):Connect-MgGraph -Scopes "User.Read.All"
  • 查询单个用户的同步时间:Get-MgUser -UserId 'user@domain.com' -Property DisplayName, UserPrincipalName, OnPremisesLastSyncDateTime | Select-Object DisplayName, UserPrincipalName, OnPremisesLastSyncDateTime
  • 批量查询所有同步用户:Get-MgUser -All $true -Property DisplayName, UserPrincipalName, OnPremisesLastSyncDateTime | Where-Object { $_.OnPremisesLastSyncDateTime -ne $null } | Select-Object DisplayName, UserPrincipalName, OnPremisesLastSyncDateTime

注意:仅从本地AD同步到Azure AD的用户会有OnPremisesLastSyncDateTime属性,纯云创建的用户该值为null。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.21 18:03:17