简体   繁体   English

如何从PowerShell的AzureAD v2 cmdlet访问新创建的应用程序的ObjectId?

[英]How to access the newly created application's ObjectId from AzureAD v2 cmdlet for PowerShell?

有没有办法在AzureAD v2 cmdlet for PowerShellAzureAD v2 cmdlet for PowerShell新创建的应用程序的最新ObjectId

The result of the PowerShell cmdlet New-AzureADApplication will be the Application object, including the ObjectId attribute: PowerShell cmdlet New-AzureADApplication将是Application对象,包括ObjectId属性:

PS C:\> New-AzureADApplication -DisplayName "My Special App" -IdentifierUris @("https://localhost/my-special-app")
ObjectId                             AppId                                DisplayName
--------                             -----                                ----------
4a9c0714-adf9-42f4-9189-a69fa2c33861 0f6b4c20-957a-4c96-b477-5562995fd920 My Special App

The best way to use do this in your script is to place the result in a variable: 在脚本中执行此操作的最佳方法是将结果放入变量中:

PS C:\> $app = New-AzureADApplication -DisplayName "My Special App" -IdentifierUris @("https://localhost/my-special-app")
PS C:\> $app.ObjectId
4a9c0714-adf9-42f4-9189-a69fa2c33861

If you're looking for the ObjectId of an Application object which already exists, you would search for it by name: 如果要查找已经存在的Application对象的ObjectId ,则可以按名称搜索它:

PS C:\> Get-AzureADApplication -SearchString "My"
ObjectId                             AppId                                DisplayName
--------                             -----                                -----------
4a9c0714-adf9-42f4-9189-a69fa2c33861 0f6b4c20-957a-4c96-b477-5562995fd920 My Special App
4254aa16-b04d-4ce8-9d0b-9b439984499a a4dfe0f4-4406-4906-af67-7201aef85db7 My Other Special App

(Note: The -SearchString parameter does "startswith" searches, not "contains".) (注意: -SearchString参数执行“ startswith”搜索,而不是“ contains”。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从二进制 PowerShell Cmdlet 访问模块的私有数据? - How to access module's privatedata from a binary PowerShell Cmdlet? 使用AzureAD v2 for Powershell禁用AD Connect - Disabling AD Connect using AzureAD v2 for Powershell 从 C# 以编程方式调用 CmdLet 时,如何捕获 Powershell CmdLet 的详细输出 - How to capture a Powershell CmdLet's verbose output when the CmdLet is programmatically Invoked from C# 如何从C#以编程方式调用CmdLet时捕获Powershell CmdLet的Object输出 - How to capture a Powershell CmdLet's Object output when the CmdLet is programmatically Invoked from C# 删除使用New-SqlHadrEndPoint创建的终结点的Powershell cmdlet是什么? - What's the Powershell cmdlet to delete an endpoint created with New-SqlHadrEndPoint? powershell cmdlet:位置与管道是否相互对立? - powershell cmdlet: positional v.s. pipeline are they against each other? 使用Powershell创建新的AzureAD应用程序 - Creation of new AzureAD application with powershell 如何在v1.0中以编程方式从PowerShell cmdlet获取警告输出? - How can I get warning output from a PowerShell cmdlet programatically in v1.0? 从 Powershell V5 转换为 Powershell V2 - Conversion from Powershell V5 to Powershell V2 使用C#中的powershell cmdlet重新启动Hyper V计算机 - Restart Hyper V machine using powershell cmdlet from C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM