【发布时间】:2023-03-30 14:54:01
【问题描述】:
我需要能够在非交互模式下运行Connect-ADAccount,邀请用户加入我的 AD,为这个新用户分配一些资源权限。
所以我有:
创建了一个服务主体。
使用以下代码创建了一个证书:
Connect-AzureAD
$Certname = Read-Host "Enter Certificate Name"
$Cert = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname $Certname -Provider “Microsoft Enhanced RSA and AES Cryptographic Provider”
$pw = ConvertTo-SecureString -String "Pazzword" -Force -AsPlainText
$thumbprint = $Cert.Thumbprint
Export-PfxCertificate -cert cert:\localMachine\my\$thumbprint -FilePath $env:USERPROFILE\Desktop\$Certname.pfx -Password $pw
Get-PfxCertificate -FilePath $env:USERPROFILE\Desktop\$Certname.pfx | Export-Certificate -FilePath
$env:USERPROFILE\Desktop\OutputCert.crt -Type Cert
手动上传。
向我的服务主体授予所有者权限。
现在我可以运行以下代码,但它会在 New-AzureADMSInvitation 步骤中失败。
Connect-AzureAD -TenantId $ObjectId -ApplicationId $AppId -CertificateThumbprint $thumb
New-AzureADMSInvitation -InvitedUserDisplayName $userName -InvitedUserEmailAddress $userEmail -InviteRedirectUrl 'https://portal.azure.com/' -SendInvitationMessage $true
我不确定在这种情况下需要什么权限。
New-AzureADMSInvitation : Error occurred while executing NewAzureADMSInvitation
Code: Unauthorized
Message: Insufficient privileges to perform requested operation by the application '00000003-0000-0000-c000-000000000000'. ControllerName=MSGraphInviteAPI, ActionName=CreateInvite [...]
【问题讨论】:
-
您向服务主体授予了所有者权限?
标签: azure powershell