iT邦幫忙

1

Connect-AzureAD 的 powershell 指令

  • 分享至 

  • xImage

請教
Connect-AzureAD 的指令能否查詢帳號的狀態是否有鎖住或是其他指令有類似作用的? 謝謝

https://ithelp.ithome.com.tw/upload/images/20260318/20003705jctdJHphQi.png

圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
s930109
iT邦新手 5 級 ‧ 2026-03-18 15:40:25
  1. 使用 AzureAD 模組 (舊版)
    如果你目前環境中仍在使用此模組,連線後可以使用以下指令:
    查詢特定使用者
Get-AzureADUser -ObjectId "user@example.com" | Select-Object DisplayName, AccountEnabled, UserPrincipalName

AccountEnabled:

True: 帳號為啟用狀態。

False: 帳號被禁用 (Disabled)。

注意: Azure AD 模組對於「密碼嘗試錯誤導致的暫時鎖定 (Lockout)」資訊揭露較少,通常只能看到是否被管理員「停用」。


  1. 使用 Microsoft Graph 模組 (推薦新版)
    第一步:安裝與連線
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.Read.All"

第二步:查詢帳號狀態

# 查詢帳號是否啟用以及登入錯誤狀態
Get-MgUser -UserId "user@example.com" -Property DisplayName, AccountEnabled, SignInActivity | Select-Object DisplayName, AccountEnabled, @{n='LastSignIn';e={$_.SignInActivity.LastSignInDateTime}}

問AI給的答案~

我要發表回答

立即登入回答