Skip to content

Commit 8c0e0c7

Browse files
authored
Merge pull request #181 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents d7a81c7 + 19eb567 commit 8c0e0c7

14 files changed

+211
-158
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Groups/Invoke-EditGroup.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function Invoke-EditGroup {
3434
try {
3535
$member = $_.value
3636
$memberid = $_.addedFields.id
37+
if (!$memberid) {
38+
$memberid = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$member" -tenantid $TenantId).id
39+
}
3740

3841
if ($GroupType -eq 'Distribution List' -or $GroupType -eq 'Mail-Enabled Security') {
3942
$Params = @{ Identity = $userobj.groupid; Member = $member; BypassSecurityGroupManagerCheck = $true }
@@ -262,7 +265,7 @@ function Invoke-EditGroup {
262265
foreach ($GraphLog in $GraphLogs) {
263266
$GraphError = $RawGraphRequest | Where-Object { $_.id -eq $GraphLog.id -and $_.status -notmatch '^2[0-9]+' }
264267
if ($GraphError) {
265-
$Message = $GraphError.body.error.message
268+
$Message = Get-NormalizedError -message $GraphError.body.error
266269
$Sev = 'Error'
267270
$Results.Add("Error - $Message")
268271
} else {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecOffboardUser.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Function Invoke-ExecOffboardUser {
1010
[CmdletBinding()]
1111
param($Request, $TriggerMetadata)
1212
$AllUsers = $Request.Body.user.value
13-
$TenantFilter = $request.Body.tenantFilter.value
13+
$TenantFilter = $request.Body.tenantFilter.value ? $request.Body.tenantFilter.value : $request.Body.tenantFilter
1414
$Results = foreach ($username in $AllUsers) {
1515
try {
1616
$APIName = 'ExecOffboardUser'

Modules/CIPPCore/Public/GraphHelper/Get-CippException.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function Get-CippException {
88
Message = $Exception.Exception.Message
99
NormalizedError = Get-NormalizedError -message $Exception.Exception.Message
1010
Position = $Exception.InvocationInfo.PositionMessage
11+
StackTrace = ($Exception.ScriptStackTrace | Out-String)
1112
ScriptName = $Exception.InvocationInfo.ScriptName
1213
LineNumber = $Exception.InvocationInfo.ScriptLineNumber
1314
Category = $Exception.CategoryInfo.ToString()
Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,72 @@
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

Comments
 (0)