使用AZ Powershell模块注册本机应用程序

问题描述 投票:0回答:2

我需要使用AZ Powershell 6模块在Azure Active Directory上注册本机应用程序。可以使用AzureAD模块中的命令New-AzureADApplication注册本机应用程序,将“PublicClient”字段的值设置为true,但PowerShell 6不支持模块AzureAD。

在powershell 6中,似乎相应的命令是New-AzADApplication,它允许注册Web应用程序/ API而不是本机应用程序。

那么如何在PowerShell 6中使用模块AZ注册本机应用程序呢?

谢谢。

powershell azure-active-directory registration nativeapplication
2个回答
1
投票

似乎不支持使用Az直接创建本机应用程序。 Azure发布了一个名为AzureAD.Standard.Preview的AzureAD模块预览版,它支持Powershell Core 6,该模块提供与AzureAD相同的功能。您可以像AzureAD一样使用它来创建本机应用程序。

PowerShell Gallery:https://www.poshtestgallery.com/packages/AzureAD.Standard.Preview/0.1.599.7

Install-Module -Name AzureAD.Standard.Preview

有关更多详细信息,请参阅:Azure AD PowerShell module with support for PowerShell Core


2
投票

如果您尝试Install-Module -Name AzureAD.Standard.Preview,您将收到以下错误:

"PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'AzureAD.Standard.Preview'. Try Get-PSRepository to see all available registered module repositories.
At C:\program files\powershell\6\Modules\PowerShellGet\PSModule.psm1:9491 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage"

因此,您必须使用以下命令添加存储库:

PS> Register-PSRepository -Name PreviewRepository -SourceLocation 'https://www.poshtestgallery.com/api/v1'

然后安装并导入模块

PS> Install-Module -Name AzureAD.Standard.Preview
PS> Import-Module AzureAD.Standard.Preview

检查模块是否已正确安装并导入所有命令。

PS> Get-Module -ListAvailable

记得在Connect-AzureAD之前总是打电话给Login-AzAccount,否则你会收到一个错误。

感谢Joy Wang和最诚挚的问候。

© www.soinside.com 2019 - 2024. All rights reserved.