Forum Discussion
GarethParry
Sep 14, 2022Copper Contributor
get-mailbox powershell command no longer works
Hi, i have been running the command Get-Mailbox |Select-Object DisplayName, PrimarySmtpAddress |Sort-Object DisplayName | Export-CSV C:\IT\Powershell\Users.csv as part of a powers...
- Oct 07, 2022Are you sure that the certificates, applications, and organization (tenant) you're trying to use all line up? Get-ExoMailbox complains about a token mismatch.
You know that you can run the code interactively, so that means that when authentication works, the code works. The problem here is how you're trying to authenticate. Given that you're using CBA, it's likely something to do with the certificate. Has the certificate expired?
GarethParry
Oct 07, 2022Copper Contributor
hi,
i get a new error now
Get-ExoMailbox : Error while querying REST service. HttpStatusCode=401 ErrorMessage=Microsoft.Exchange.Admin.OData.Core.ODataServiceException:
CrossTenantAccessNotAllowed: For AppOnly flow Tenant in token e******s.onmicrosoft.com doesn't match with Tenant in request Url b*****t.com.
at Microsoft.Exchange.AdminApi.Common.AdminApiUtils.VerifyTenantInIdentityAndUrlMatchForAppOnly(HttpContextBase httpContext)
at Microsoft.Exchange.Admin.Library.BetaHttpHandler.ProcessRequest(HttpContext context)Microsoft.Exchange.Admin.OData.Core.ODataServiceException:
CrossTenantAccessNotAllowed: For AppOnly flow Tenant in token e******s.onmicrosoft.com doesn't match with Tenant in request Url b*****t.com.
at Microsoft.Exchange.AdminApi.Common.AdminApiUtils.VerifyTenantInIdentityAndUrlMatchForAppOnly(HttpContextBase httpContext)
at Microsoft.Exchange.Admin.Library.BetaHttpHandler.ProcessRequest(HttpContext context)
At C:\IT\Powershell\OfficeUsers.ps1:10 char:1
+ Get-ExoMailbox |Select-Object DisplayName, PrimarySmtpAddress |Sort-O ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ProtocolError: (:) [Get-EXOMailbox], RestClientException
+ FullyQualifiedErrorId : An error occurred while processing this request.,Microsoft.Exchange.Management.RestApiClient.GetExoMailboxTonyRedmond
Oct 07, 2022MVP
Are you sure that the certificates, applications, and organization (tenant) you're trying to use all line up? Get-ExoMailbox complains about a token mismatch.
You know that you can run the code interactively, so that means that when authentication works, the code works. The problem here is how you're trying to authenticate. Given that you're using CBA, it's likely something to do with the certificate. Has the certificate expired?
You know that you can run the code interactively, so that means that when authentication works, the code works. The problem here is how you're trying to authenticate. Given that you're using CBA, it's likely something to do with the certificate. Has the certificate expired?
- GarethParryOct 07, 2022Copper Contributorhi thanks for this you steared me in the right direction. our tenent anema nd domain name are not the same and it didint like the entry i had for organisation. It used to work so i guess they changed something in the last few weeks.