Microsoft Entra PowerShell 是一款強大的工具,可直接從 PowerShell 管理與管理 Entra 資源。
本文將協助你理解模組並概述其核心概念。
先決條件
登入
Microsoft Entra PowerShell 中的每個 cmdlet 都受到一個或多個權限範圍的保護。 使用 Microsoft Entra PowerShell 時,登入的使用者必須同意他們計劃使用的 cmdlet 所需的權限範圍。 在 cmdlet 中指定權限 Connect-Entra 。 如果被要求,請用你的租戶管理員帳號登入。
Connect-Entra -Scopes 'User.Read.All'
Microsoft Entra PowerShell 支援兩種認證方式:委派存取與僅應用程式存取。 要查看所有可能選項,請參考 認證情境。
查找可用指令
Microsoft Entra PowerShell cmdlets 遵循 PowerShell 的標準命名規則。 Verb-Noun 動詞描述行動(例如、NewGetSetRemove),名詞描述資源類型(例如、)。UserGroupServicePrincipalDevice Microsoft Entra PowerShell 中的名詞一律以 Entra 為前綴。 完整標準動詞列表,請參閱 PowerShell 指令核准的動詞。
Note
對於 Beta 指令,資源名稱後加上 Beta 前綴。 例如,Beta 版本用 Get-EntraBetaUser 代替 Get-EntraUser 。
您可以使用以下指令取得 Microsoft Entra PowerShell 模組中所有可用的指令:
Get-Command -Module Microsoft.Entra*
例如,要縮小範圍,尋找與應用程式相關的指令,請執行以下指令。
Get-Command -Module Microsoft.Entra* -Noun *application*
此指令顯示模組中應用程式資源中包含的所有指令碼、函式與別名。
CommandType Name Version Source
----------- ---- ------- ------
Function Add-EntraApplicationOwner 1.0.1 Microsoft.Entra
Function Get-EntraApplication 1.0.1 Microsoft.Entra
Function Get-EntraApplicationExtensionProperty 1.0.1 Microsoft.Entra
Function Get-EntraApplicationKeyCredential 1.0.1 Microsoft.Entra
Function Get-EntraApplicationLogo 1.0.1 Microsoft.Entra
Function Get-EntraApplicationOwner 1.0.1 Microsoft.Entra
Function Get-EntraApplicationPasswordCredential 1.0.1 Microsoft.Entra
查看指令所支援的屬性與方法
若想查看預設輸出以外的更多屬性,請執行以下指令以查看所有支援的屬性:
Get-EntraUser -UserId 'rsmith@contoso.com' | Get-Member
此指令顯示所有使用者屬性與方法。
accountEnabled NoteProperty bool accountEnabled=True
ageGroup NoteProperty object ageGroup=null
businessPhones NoteProperty Object[]
city NoteProperty string city=Bellevue
companyName NoteProperty object companyName=null
consentProvidedForMinor NoteProperty object
country NoteProperty string
createdDateTime NoteProperty datetime createdDateTime
creationType NoteProperty object creationType=null
deletedDateTime NoteProperty object deletedDateTime=null
DeletionTimestamp NoteProperty object DeletionTimestamp=null
department NoteProperty string department=Retail
DirSyncEnabled NoteProperty object DirSyncEnabled=null
displayName NoteProperty string displayName=Adele Vance
employeeHireDate NoteProperty object employeeHireDate=null
employeeId NoteProperty object employeeId=null
employeeLeaveDateTime NoteProperty object employeeLeaveDateTime=null
employeeOrgData NoteProperty object employeeOrgData=null
employeeType NoteProperty object employeeType=null
尋求幫助
要尋求 Microsoft Entra PowerShell 指令集的協助,請使用 Get-Help Command,以獲得關於特定命令的詳細說明,包括語法、參數及使用範例。
例如,若要進一步了解 Get-EntraUser 指令,請執行下列指令。
Get-Help Get-EntraUser -Detailed
此指令提供詳細的說明文件,包括指令長的描述、參數、使用範例及相關指令,幫助你了解如何在各種情境下有效使用。
了解基本知識
透過我們詳細的操作指南,親手操作 Microsoft Entra PowerShell: