forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request KelvinTegelaar#485 from KelvinTegelaar/dev
Dev to release
- Loading branch information
Showing
68 changed files
with
998 additions
and
572 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,26 @@ $results = foreach ($tenant in $SelectedTenants) { | |
try { | ||
$email = if ($groupobj.domain) { "$($groupobj.username)@$($groupobj.domain)" } else { "$($groupobj.username)@$($tenant)" } | ||
if ($groupobj.groupType -in "Generic", "azurerole", "dynamic") { | ||
|
||
$BodyToship = [pscustomobject] @{ | ||
"displayName" = $groupobj.Displayname | ||
"description" = $groupobj.Description | ||
"mailNickname" = $groupobj.username | ||
mailEnabled = [bool]$false | ||
securityEnabled = [bool]$true | ||
isAssignableToRole = [bool]($groupobj | Where-Object -Property groupType -EQ "AzureRole") | ||
|
||
} | ||
} | ||
if ($groupobj.membershipRules) { | ||
$BodyToship | Add-Member -NotePropertyName "membershipRule" -NotePropertyValue ($groupobj.membershipRules) | ||
$BodyToship | Add-Member -NotePropertyName "groupTypes" -NotePropertyValue @("DynamicMembership") | ||
$BodyToship | Add-Member -NotePropertyName "membershipRuleProcessingState" -NotePropertyValue "On" | ||
} | ||
if ($groupobj.AddOwner -AND $groupobj.groupType -in "generic", "azurerole", "security") { | ||
$BodyToship | Add-Member -NotePropertyName "[email protected]" -NotePropertyValue (($groupobj.AddOwner) | ForEach-Object { "https://graph.microsoft.com/v1.0/users/$($_.value)" }) | ||
} | ||
if ($groupobj.AddMember -AND $groupobj.groupType -in "generic", "azurerole", "security") { | ||
$BodyToship | Add-Member -NotePropertyName "[email protected]" -NotePropertyValue (($groupobj.AddMember) | ForEach-Object { "https://graph.microsoft.com/v1.0/users/$($_.value)" }) | ||
} | ||
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups" -tenantid $tenant -type POST -body (ConvertTo-Json -InputObject $BodyToship -Depth 10) -verbose | ||
} | ||
else { | ||
|
@@ -43,6 +48,7 @@ $results = foreach ($tenant in $SelectedTenants) { | |
RequireSenderAuthenticationEnabled = [bool]!$groupobj.AllowExternal | ||
} | ||
$GraphRequest = New-ExoRequest -tenantid $tenant -cmdlet "New-DistributionGroup" -cmdParams $params | ||
# At some point add logic to use AddOwner/AddMember for New-DistributionGroup, but idk how we're going to brr that - rvdwegen | ||
} | ||
"Successfully created group $($groupobj.displayname) for $($tenant)" | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Created group $($groupobj.displayname) with id $($GraphRequest.id) " -Sev "Info" | ||
|
@@ -51,7 +57,6 @@ $results = foreach ($tenant in $SelectedTenants) { | |
catch { | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Group creation API failed. $($_.Exception.Message)" -Sev "Error" | ||
"Failed to create group. $($groupobj.displayname) for $($tenant) $($_.Exception.Message)" | ||
|
||
} | ||
} | ||
$body = [pscustomobject]@{"Results" = @($results) } | ||
|
@@ -60,4 +65,4 @@ $body = [pscustomobject]@{"Results" = @($results) } | |
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $Body | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.