|
1 | | -function Get-NormalizedError { |
2 | | - <# |
3 | | - .FUNCTIONALITY |
4 | | - Internal |
5 | | - #> |
6 | | - [CmdletBinding()] |
7 | | - param ( |
8 | | - [string]$message |
9 | | - ) |
10 | | - |
11 | | - #Check if the message is valid JSON. |
12 | | - try { |
13 | | - $JSONMsg = $message | ConvertFrom-Json |
14 | | - } catch { |
15 | | - } |
16 | | - #if the message is valid JSON, there can be multiple fields in which the error resides. These are: |
17 | | - # $message.error.Innererror.Message |
18 | | - # $message.error.Message |
19 | | - # $message.error.details.message |
20 | | - # $message.error.innererror.internalException.message |
21 | | - |
22 | | - #We need to check if the message is in one of these fields, and if so, return it. |
23 | | - if ($JSONMsg.error.innererror.message) { |
24 | | - Write-Host "innererror.message found: $($JSONMsg.error.innererror.message)" |
25 | | - $message = $JSONMsg.error.innererror.message |
26 | | - } elseif ($JSONMsg.error.message) { |
27 | | - Write-Host "error.message found: $($JSONMsg.error.message)" |
28 | | - $message = $JSONMsg.error.message |
29 | | - } elseif ($JSONMsg.error.details.message) { |
30 | | - Write-Host "error.details.message found: $($JSONMsg.error.details.message)" |
31 | | - $message = $JSONMsg.error.details.message |
32 | | - } elseif ($JSONMsg.error.innererror.internalException.message) { |
33 | | - Write-Host "error.innererror.internalException.message found: $($JSONMsg.error.innererror.internalException.message)" |
34 | | - $message = $JSONMsg.error.innererror.internalException.message |
35 | | - } |
36 | | - |
37 | | - |
38 | | - #finally, put the message through the translator. If it's not in the list, just return the original message |
39 | | - switch -Wildcard ($message) { |
40 | | - 'Request not applicable to target tenant.' { 'Required license not available for this tenant' } |
41 | | - "Neither tenant is B2C or tenant doesn't have premium license" { 'This feature requires a P1 license or higher' } |
42 | | - 'Response status code does not indicate success: 400 (Bad Request).' { 'Error 400 occured. There is an issue with the token configuration for this tenant. Please perform an access check' } |
43 | | - '*Microsoft.Skype.Sync.Pstn.Tnm.Common.Http.HttpResponseException*' { 'Could not connect to Teams Admin center - Tenant might be missing a Teams license' } |
44 | | - '*Provide valid credential.*' { 'Error 400: There is an issue with your Exchange Token configuration. Please perform an access check for this tenant' } |
45 | | - '*This indicate that a subscription within the tenant has lapsed*' { 'There is subscription for this service available, Check licensing information.' } |
46 | | - '*User was not found.*' { 'The relationship between this tenant and the partner has been dissolved from the tenant side.' } |
47 | | - '*AADSTS50020*' { 'AADSTS50020: The user you have used for your Secure Application Model is a guest in this tenant, or your are using GDAP and have not added the user to the correct group. Please delete the guest user to gain access to this tenant' } |
48 | | - '*AADSTS50177' { 'AADSTS50177: The user you have used for your Secure Application Model is a guest in this tenant, or your are using GDAP and have not added the user to the correct group. Please delete the guest user to gain access to this tenant' } |
49 | | - '*invalid or malformed*' { 'The request is malformed. Have you finished the SAM Setup?' } |
50 | | - '*Windows Store repository apps feature is not supported for this tenant*' { 'This tenant does not have WinGet support available' } |
51 | | - '*AADSTS650051*' { 'The application does not exist yet. Try again in 30 seconds.' } |
52 | | - '*AppLifecycle_2210*' { 'Failed to call Intune APIs: Does the tenant have a license available?' } |
53 | | - '*One or more added object references already exist for the following modified properties:*' { 'This user is already a member of this group.' } |
54 | | - '*Microsoft.Exchange.Management.Tasks.MemberAlreadyExistsException*' { 'This user is already a member of this group.' } |
55 | | - '*The property value exceeds the maximum allowed size (64KB)*' { 'One of the values exceeds the maximum allowed size (64KB).' } |
56 | | - '*Unable to initialize the authorization context*' { 'Your GDAP configuration does not allow us to write to this tenant, please check your group mappings and tenant onboarding.' } |
57 | | - '*Providers.Common.V1.CoreException*' { '403 (Access Denied) - We cannot connect to this tenant.' } |
58 | | - '*Authentication failed. MFA required*' { 'Authentication failed. MFA required' } |
59 | | - '*Your tenant is not licensed for this feature.*' { 'Required license not available for this tenant' } |
60 | | - '*AADSTS65001*' { 'We cannot access this tenant as consent has not been given, please try refreshing the CPV permissions in the application settings menu.' } |
61 | | - '*AADSTS700082*' { 'The CIPP user access token has expired. Run the SAM Setup wizard to refresh your tokens.' } |
62 | | - '*Account is not provisioned.' { 'The account is not provisioned. You do not the correct M365 license to access this information..' } |
63 | | - '*AADSTS5000224*' { 'This resource is not available - Has this tenant been deleted?' } |
64 | | - '*AADSTS53003*' { 'Access has been blocked by Conditional Access policies. Please check the Conditional Access configuration documentation' } |
65 | | - '*AADSTS900023*' { 'This tenant is not available for this operation. Please check the selected tenant and try again.' } |
66 | | - '*AADSTS9002313*' { 'The credentials used to connect to the Graph API are not available, please retry. If this issue persists you may need to execute the SAM wizard.' } |
67 | | - '*One or more platform(s) is/are not configured for the customer. Please configure the platform before trying to purchase a SKU.*' { 'One or more platform(s) is/are not configured for the customer. Please configure the platform before trying to purchase a SKU.' } |
68 | | - Default { $message } |
69 | | - |
70 | | - } |
71 | | -} |
| 1 | +function Get-NormalizedError { |
| 2 | + <# |
| 3 | + .FUNCTIONALITY |
| 4 | + Internal |
| 5 | + #> |
| 6 | + [CmdletBinding()] |
| 7 | + param ( |
| 8 | + [string]$message |
| 9 | + ) |
| 10 | + |
| 11 | + #Check if the message is valid JSON. |
| 12 | + try { |
| 13 | + $JSONMsg = $message | ConvertFrom-Json |
| 14 | + } catch { |
| 15 | + } |
| 16 | + #if the message is valid JSON, there can be multiple fields in which the error resides. These are: |
| 17 | + # $message.error.Innererror.Message |
| 18 | + # $message.error.Message |
| 19 | + # $message.error.details.message |
| 20 | + # $message.error.innererror.internalException.message |
| 21 | + |
| 22 | + #We need to check if the message is in one of these fields, and if so, return it. |
| 23 | + if ($JSONMsg.error.innererror.message) { |
| 24 | + Write-Host "innererror.message found: $($JSONMsg.error.innererror.message)" |
| 25 | + $message = $JSONMsg.error.innererror.message |
| 26 | + } elseif ($JSONMsg.error.message) { |
| 27 | + Write-Host "error.message found: $($JSONMsg.error.message)" |
| 28 | + $message = $JSONMsg.error.message |
| 29 | + } elseif ($JSONMsg.error.details.message) { |
| 30 | + Write-Host "error.details.message found: $($JSONMsg.error.details.message)" |
| 31 | + $message = $JSONMsg.error.details.message |
| 32 | + } elseif ($JSONMsg.error.innererror.internalException.message) { |
| 33 | + Write-Host "error.innererror.internalException.message found: $($JSONMsg.error.innererror.internalException.message)" |
| 34 | + $message = $JSONMsg.error.innererror.internalException.message |
| 35 | + } |
| 36 | + |
| 37 | + |
| 38 | + #finally, put the message through the translator. If it's not in the list, just return the original message |
| 39 | + switch -Wildcard ($message) { |
| 40 | + 'Request not applicable to target tenant.' { 'Required license not available for this tenant' } |
| 41 | + "Neither tenant is B2C or tenant doesn't have premium license" { 'This feature requires a P1 license or higher' } |
| 42 | + 'Response status code does not indicate success: 400 (Bad Request).' { 'Error 400 occured. There is an issue with the token configuration for this tenant. Please perform an access check' } |
| 43 | + '*Microsoft.Skype.Sync.Pstn.Tnm.Common.Http.HttpResponseException*' { 'Could not connect to Teams Admin center - Tenant might be missing a Teams license' } |
| 44 | + '*Provide valid credential.*' { 'Error 400: There is an issue with your Exchange Token configuration. Please perform an access check for this tenant' } |
| 45 | + '*This indicate that a subscription within the tenant has lapsed*' { 'There is subscription for this service available, Check licensing information.' } |
| 46 | + '*User was not found.*' { 'The relationship between this tenant and the partner has been dissolved from the tenant side.' } |
| 47 | + '*AADSTS50020*' { 'AADSTS50020: The user you have used for your Secure Application Model is a guest in this tenant, or your are using GDAP and have not added the user to the correct group. Please delete the guest user to gain access to this tenant' } |
| 48 | + '*AADSTS50177' { 'AADSTS50177: The user you have used for your Secure Application Model is a guest in this tenant, or your are using GDAP and have not added the user to the correct group. Please delete the guest user to gain access to this tenant' } |
| 49 | + '*invalid or malformed*' { 'The request is malformed. Have you finished the SAM Setup?' } |
| 50 | + '*Windows Store repository apps feature is not supported for this tenant*' { 'This tenant does not have WinGet support available' } |
| 51 | + '*AADSTS650051*' { 'The application does not exist yet. Try again in 30 seconds.' } |
| 52 | + '*AppLifecycle_2210*' { 'Failed to call Intune APIs: Does the tenant have a license available?' } |
| 53 | + '*One or more added object references already exist for the following modified properties:*' { 'This user is already a member of this group.' } |
| 54 | + '*Microsoft.Exchange.Management.Tasks.MemberAlreadyExistsException*' { 'This user is already a member of this group.' } |
| 55 | + '*The property value exceeds the maximum allowed size (64KB)*' { 'One of the values exceeds the maximum allowed size (64KB).' } |
| 56 | + '*Unable to initialize the authorization context*' { 'Your GDAP configuration does not allow us to write to this tenant, please check your group mappings and tenant onboarding.' } |
| 57 | + '*Providers.Common.V1.CoreException*' { '403 (Access Denied) - We cannot connect to this tenant.' } |
| 58 | + '*Authentication failed. MFA required*' { 'Authentication failed. MFA required' } |
| 59 | + '*Your tenant is not licensed for this feature.*' { 'Required license not available for this tenant' } |
| 60 | + '*AADSTS65001*' { 'We cannot access this tenant as consent has not been given, please try refreshing the CPV permissions in the application settings menu.' } |
| 61 | + '*AADSTS700082*' { 'The CIPP user access token has expired. Run the SAM Setup wizard to refresh your tokens.' } |
| 62 | + '*Account is not provisioned.' { 'The account is not provisioned. You do not the correct M365 license to access this information..' } |
| 63 | + '*AADSTS5000224*' { 'This resource is not available - Has this tenant been deleted?' } |
| 64 | + '*AADSTS53003*' { 'Access has been blocked by Conditional Access policies. Please check the Conditional Access configuration documentation' } |
| 65 | + '*AADSTS900023*' { 'This tenant is not available for this operation. Please check the selected tenant and try again.' } |
| 66 | + '*AADSTS9002313*' { 'The credentials used to connect to the Graph API are not available, please retry. If this issue persists you may need to execute the SAM wizard.' } |
| 67 | + '*One or more platform(s) is/are not configured for the customer. Please configure the platform before trying to purchase a SKU.*' { 'One or more platform(s) is/are not configured for the customer. Please configure the platform before trying to purchase a SKU.' } |
| 68 | + "One or more added object references already exist for the following modified properties: 'members'." { 'This user is already a member of the selected group.' } |
| 69 | + Default { $message } |
| 70 | + |
| 71 | + } |
| 72 | +} |
0 commit comments