英文:
PnP PowerShell: Bad Request when attempting to create a PnPAzureAD App
问题
在PowerShell 7.2上运行以下命令时:
Register-PnPAzureADApp -ApplicationName TestApp -Tenant yourtenant.onmicrosoft.com -Store CurrentUser -Username "yourname@domain.com" -Password (Read-Host -AsSecureString -Prompt "Enter Password")
在执行时返回了一个错误的请求错误:
Register-PnPAzureADApp: {"error":{"code":"Request_BadRequest","message":"发现了一个具有预期类型 'Edm.String[Nullable=False]' 的空值。预期类型 'Edm.String[Nullable=False]' 不允许空值。","innerError":{"date":"2023-07-31T14:21:28","request-id":"7dbf66db-f159-45dc-b061-7a1dcdc9e323","client-request-id":"7dbf66db-f159-45dc-b061-7a1dcdc9e323"}}}
有人了解这个命令可能出现的问题吗?我不确定是我的环境问题还是其他因素。任何帮助都将不胜感激!
遵循Azure AD App Only Authentication in SharePoint Online using PnP PowerShell,并期望获得一个可在我的Azure Functions应用程序中使用的证书。
英文:
When running the following command on PowerShell 7.2: Register-PnPAzureADApp -ApplicationName TestApp -Tenant yourtenant.onmicrosoft.com -Store CurrentUser -Username "yourname@domain.com" -Password (Read-Host -AsSecureString -Prompt "Enter Password")
A bad request error is returned on execution:
Register-PnPAzureADApp: {"error":{"code":"Request_BadRequest","message":"A null value was found with the expected type 'Edm.String[Nullable=False]'. The expected type 'Edm.String[Nullable=False]' does not allow null values.","innerError":{"date":"2023-07-31T14:21:28","request-id":"7dbf66db-f159-45dc-b061-7a1dcdc9e323","client-request-id":"7dbf66db-f159-45dc-b061-7a1dcdc9e323"}}}
Does anybody have some insight as to what might be the issue with the command? I am unsure if it is an issue with my environment or some other factor. Any help is appreciated!
Following Azure AD App Only Authentication in SharePoint Online using PnP PowerShell and expected to have obtained a certificate that I could use in my Azure-Functions application.
答案1
得分: 0
你在运行 Register-PnPAzureADApp
命令时遇到的错误表明可能存在传递给该命令的参数的问题。错误消息明确提到找到了一个 null 值,而期望的类型不允许 null 值。
我在我的环境中尝试了相同的命令,成功创建了名为 application
的应用程序。
Register-PnPAzureADApp -ApplicationName TestApp1 -Tenant abc..com -Store CurrentUser -Username "Abc..com" -Password (Read-Host -AsSecureString -Prompt "Enter Password")
输出:
如果你仍然遇到上述命令的问题,请尝试以下命令来创建一个 AzureAD
应用程序。
方法 1:
尝试使用 App-Only 身份验证
:不要使用 -Username
和 -Password
参数进行基于用户的身份验证,而是尝试使用交互模式的 app-only 身份验证。
Register-PnPAzureADApp -ApplicationName SPSitesSelected -Tenant abc.com -Store CurrentUser -SharePointApplicationPermissions "Sites.Selected" -Interactive
方法 2:
尝试使用 App-Only 身份验证
:不要使用 -Username
和 -Password
参数进行基于用户的身份验证,而是尝试使用具有证书的 app-only 身份验证。
Register-PnPAzureADApp -ApplicationName TestApp -Tenant abc.com -CertificatePath c:\certificate.pfx -CertificatePassword (ConvertTo-SecureString -String "password" -AsPlainText -Force) -Username "yourname@domain.com" -Password (Read-Host -AsSecureString -Prompt "Enter password")
英文:
The error you encountered while running the Register-PnPAzureADApp
cmdlet indicates that there might be an issue with the parameters being passed to the cmdlet. The error message specifically mentions that a null value was found with an expected type that does not allow null values.
I tried the same command in my environment, and it created the application
successfully.
Register-PnPAzureADApp -ApplicationName TestApp1 -Tenant abc..com -Store CurrentUser -Username "Abc..com" -Password (Read-Host -AsSecureString -Prompt "Enter Password")
Output:
If you are still facing the issue with the above command, try the below commands to create an AzureAD
application
Method 1:
Try with App-Only authentication
: Instead of using the -Username
and -Password
parameters for user-based authentication, you can try using app-only authentication with Interactive mode.
Register-PnPAzureADApp -ApplicationName SPSitesSelected -Tenant abc.com -Store CurrentUser -SharePointApplicationPermissions "Sites.Selected" -Interactive
Method 2:
Try with App-Only Authentication
: Instead of using the -Username
and -Password
parameters for user-based authentication, you can try using app-only authentication with a certificate.
Register-PnPAzureADApp -ApplicationName TestApp -Tenant abc.com -CertificatePath c:\certificate.pfx -CertificatePassword (ConvertTo-SecureString -String "password" -AsPlainText -Force) -Username "yourname@domain.com" -Password (Read-Host -AsSecureString -Prompt "Enter password")
Reference: Register-PnPAzureADApp
答案2
得分: 0
我最终使用了错误版本的PnP.PowerShell构建,在这里安装了夜间版本:Install-Module PnP.PowerShell -Scope CurrentUser -AllowPrerelease -SkipPublisherCheck
就搞定了!
英文:
I ended up using a wrong build of PnP.PowerShell, installing the nightly build with: Install-Module PnP.PowerShell -Scope CurrentUser -AllowPrerelease -SkipPublisherCheck
Did the trick!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论