Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into…
Browse files Browse the repository at this point in the history
… KelvinTegelaar-dev
  • Loading branch information
JohnDuprey committed Jul 30, 2023
2 parents 85d6ec0 + 38ac3c8 commit 9a4a71c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion AddCAPolicy/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ $JSONObj = $request.body.RawJSON | ConvertFrom-Json | Select-Object * -ExcludePr
Remove-EmptyArrays $JSONObj
#Remove context as it does not belong in the payload.
$JsonObj.grantControls.PSObject.Properties.Remove('[email protected]')
$JsonObj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.PSObject.Properties.Remove('@odata.type')
if ($JSONObj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.Members) {
$JsonObj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.PSObject.Properties.Remove('@odata.context')
$JsonObj.conditions.users.excludeGuestsOrExternalUsers.externalTenants.PSObject.Properties.Remove('@odata.type')
}
$RawJSON = $JSONObj | ConvertTo-Json -Depth 10

$results = foreach ($Tenant in $tenants) {
Expand Down
13 changes: 9 additions & 4 deletions GraphHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,10 @@ function New-ExoRequest ($tenantid, $cmdlet, $cmdParams, $useSystemMailbox, $Anc
}
Write-Host "Using $Anchor"
$Headers = @{
Authorization = "Bearer $($token.access_token)"
Prefer = 'odata.maxpagesize = 1000'
'X-AnchorMailbox' = $anchor
Authorization = "Bearer $($token.access_token)"
Prefer = 'odata.maxpagesize = 1000'
'parameter-based-routing' = $true
'X-AnchorMailbox' = $anchor

}
try {
Expand All @@ -562,7 +563,11 @@ function New-ExoRequest ($tenantid, $cmdlet, $cmdParams, $useSystemMailbox, $Anc
catch {
$ErrorMess = $($_.Exception.Message)
$ReportedError = ($_.ErrorDetails | ConvertFrom-Json -ErrorAction SilentlyContinue)
$Message = if ($ReportedError.error.details.message) { $ReportedError.error.details.message } else { $ReportedError.error.innererror.internalException.message }
$Message = if ($ReportedError.error.details.message) {
$ReportedError.error.details.message
}
elseif ($ReportedError.error.message) { $ReportedError.error.message }
else { $ReportedError.error.innererror.internalException.message }
if ($null -eq $Message) { $Message = $ErrorMess }
throw $Message
}
Expand Down
6 changes: 6 additions & 0 deletions Standards_DisableM365GroupUsers/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ param($tenant)

try {
$CurrentState = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/settings" -tenantid $tenant) | Where-Object -Property displayname -EQ 'Group.unified'
if (!$CurrentState) {
#if no current configuration is found, we set it to the default template supplied by MS.
$CurrentState = '{"id":"","displayName":"Group.Unified","templateId":"62375ab9-6b52-47ed-826b-58e47e0e304b","values":[{"name":"NewUnifiedGroupWritebackDefault","value":"true"},{"name":"EnableMIPLabels","value":"false"},{"name":"CustomBlockedWordsList","value":""},{"name":"EnableMSStandardBlockedWords","value":"false"},{"name":"ClassificationDescriptions","value":""},{"name":"DefaultClassification","value":""},{"name":"PrefixSuffixNamingRequirement","value":""},{"name":"AllowGuestsToBeGroupOwner","value":"false"},{"name":"AllowGuestsToAccessGroups","value":"true"},{"name":"GuestUsageGuidelinesUrl","value":""},{"name":"GroupCreationAllowedGroupId","value":""},{"name":"AllowToAddGuests","value":"true"},{"name":"UsageGuidelinesUrl","value":""},{"name":"ClassificationList","value":""},{"name":"EnableGroupCreation","value":"true"}]}'
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/settings/$($CurrentState.id)" -Type POST -Body $CurrentState -ContentType "application/json")
$CurrentState = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/settings" -tenantid $tenant) | Where-Object -Property displayname -EQ 'Group.unified'
}
($CurrentState.values | Where-Object { $_.name -eq 'EnableGroupCreation' }).value = "false"
$body = "{values : $($CurrentState.values | ConvertTo-Json -Compress)}"
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/settings/$($CurrentState.id)" -Type patch -Body $body -ContentType "application/json")
Expand Down

0 comments on commit 9a4a71c

Please sign in to comment.