我需要使用 AZ Powershell 6 模块在 Azure Active Directory 上注册 native 应用程序。
可以使用 AzureAD 模块中的命令 New-AzureADApplication 将“PublicClient”字段的值设置为 true 来注册 native 应用程序,但 powershell 6 不支持模块 AzureAD。
在 powershell 6 中,对应的命令似乎是 New-AzADApplication,它允许注册 Web 应用程序/API,但不能注册 native 应用程序。
那么如何在 powershell 6 中使用模块 AZ 注册 native 应用程序呢?
谢谢。
最佳答案
如果你尝试 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 和最诚挚的问候。
关于powershell - 使用 AZ Powershell 模块注册 native 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55116923/