Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
redanthrax committed Sep 26, 2023
2 parents 38ba576 + 7c16c74 commit ea085d8
Show file tree
Hide file tree
Showing 42 changed files with 740 additions and 382 deletions.
14 changes: 6 additions & 8 deletions AddAlert/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
"methods": ["get", "post"]
},
{
"type": "http",
"direction": "out",
"name": "Response"
},
{
"name": "starter",
"direction": "in",
"type": "durableClient"
"type": "queue",
"direction": "out",
"name": "Subscription",
"queueName": "AlertSubscriptions"
}
]
}
}
11 changes: 4 additions & 7 deletions AddAlert/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ $Results = foreach ($Tenant in $tenants) {
try {
$TenantID = if ($tenant -ne 'AllTenants') {
(get-tenants | Where-Object -Property defaultDomainName -EQ $Tenant).customerId
}
else {
} else {
'AllTenants'
}
if ($Request.body.SetAlerts) {
Expand Down Expand Up @@ -58,11 +57,10 @@ $Results = foreach ($Tenant in $tenants) {
EventType = $eventType
ExecutingUser = $Request.headers.'x-ms-client-principal'
}
New-CIPPGraphSubscription @params
Push-OutputBinding -Name Subscription -Value $Params
}
}
}
else {
} else {
foreach ($eventType in $Request.body.EventTypes.value) {
$params = @{
TenantFilter = $tenant
Expand All @@ -78,8 +76,7 @@ $Results = foreach ($Tenant in $tenants) {
}
"Successfully added Alert for $($Tenant) to queue."
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Successfully added Alert for $($Tenant) to queue." -Sev 'Info'
}
catch {
} catch {
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Alert for for $($Tenant) to queue" -Sev 'Error'
"Failed to add Alert for for $($Tenant) to queue $($_.Exception.message)"
}
Expand Down
12 changes: 12 additions & 0 deletions AddAlertSubscription_Queue/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scriptFile": "../Modules/CippEntryPoints/CippEntryPoints.psm1",
"entryPoint": "Receive-CippQueueTrigger",
"bindings": [
{
"name": "QueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "AlertSubscriptions"
}
]
}
75 changes: 37 additions & 38 deletions AddChocoApp/Choco.app.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{

"displayName": "",
"installCommandLine": "",
"uninstallCommandLine": "",
Expand All @@ -11,47 +10,48 @@
"fileName": "IntunePackage.intunewin",
"@odata.type": "#microsoft.graph.win32LobApp",
"applicableArchitectures": "x86, x64",

"installExperience": {
"runAsAccount": "user",
"deviceRestartBehavior": "allow",
"@odata.type": "microsoft.graph.win32LobAppInstallExperience"
},
"detectionRules": [
{
"@odata.type": "#microsoft.graph.win32LobAppFileSystemDetection",
"path": "%programfiles%\\7-zip",
"fileOrFolderName": "7z.exe",
"check32BitOn64System": false,
"detectionType": "exists" }
"@odata.type": "#microsoft.graph.win32LobAppFileSystemDetection",
"path": "%programfiles%\\7-zip",
"fileOrFolderName": "7z.exe",
"check32BitOn64System": false,
"detectionType": "exists"
}
],
"returncode": [
{
"returnCode": 0,
"type": "success",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 1707,
"type": "Success",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 1641,
"type": "hardReboot",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 1618,
"type": "retry",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 3010,
"type": "softReboot",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
}
],
"returncode": [
{
"returnCode": 0,
"type": "success",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 1707,
"type": "Success",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 1641,
"type": "hardReboot",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 1618,
"type": "retry",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
},
{
"returnCode": 3010,
"type": "softReboot",
"@odata.type": "#microsoft.graph.win32LobAppReturnCode"
}
],
"minimumNumberOfProcessors": "1",
"minimumFreeDiskSpaceInMB": "8",
"minimumCpuSpeedInMHz": "4",
Expand All @@ -60,7 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"


}
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/Immybot.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/automate.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/cwcommand.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/datto.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/huntress.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
3 changes: 2 additions & 1 deletion AddMSPApp/syncro.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"v10_1607": true
},
"notes": "CIPP Uploaded application",
"minimumMemoryInMB": "1"
"minimumMemoryInMB": "1",
"setupFilePath": "install.ps1"
}
36 changes: 18 additions & 18 deletions AddScheduledItems/function.json → AddScheduledItem/function.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
}
30 changes: 30 additions & 0 deletions AddScheduledItem/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$task = $Request.Body
$Table = Get-CIPPTable -TableName 'ScheduledTasks'

$propertiesToCheck = @('Webhook', 'Email', 'PSA')
$PostExecution = ($propertiesToCheck | Where-Object { $task.PostExecution.$_ -eq $true }) -join ','
$Parameters = ($task.Parameters | ConvertTo-Json -Compress)
if ($Parameters -eq 'null') { $Parameters = '' }
$entity = @{
PartitionKey = [string]'ScheduledTask'
TaskState = [string]'Planned'
RowKey = [string]"$(New-Guid)"
Tenant = [string]$task.TenantFilter
Name = [string]$task.Name
Command = [string]$task.Command.value
Parameters = [string]$Parameters
ScheduledTime = [string]$task.ScheduledTime
Recurrence = [string]$task.Recurrence.value
PostExecution = [string]$PostExecution
Results = 'Planned'
}
Write-Host "entity: $($entity | ConvertTo-Json)"
Add-AzDataTableEntity @Table -Entity $entity
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = @{ Results = 'Task added successfully.' }
})
20 changes: 0 additions & 20 deletions AddScheduledItems/run.ps1

This file was deleted.

26 changes: 14 additions & 12 deletions EditGroup/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ if ($AddMembers) {
$AddMembers | ForEach-Object {
try {
$member = $_
$MemberIDs = "https://graph.microsoft.com/v1.0/directoryObjects/" + (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($_)" -tenantid $Userobj.tenantid).id
if ($member -like '*#EXT#*') { $member = [System.Web.HttpUtility]::UrlEncode($member) }
$MemberIDs = "https://graph.microsoft.com/v1.0/directoryObjects/" + (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($member)" -tenantid $Userobj.tenantid).id
$addmemberbody = "{ `"[email protected]`": $(ConvertTo-Json @($MemberIDs)) }"
if ($userobj.groupType -eq "Distribution list" -or $userobj.groupType -eq "Mail-Enabled Security") {
$Params = @{ Identity = $userobj.groupid; Member = $member; BypassSecurityGroupManagerCheck = $true }
Expand Down Expand Up @@ -47,11 +48,12 @@ if ($AddContacts) {
New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Add-DistributionGroupMember" -cmdParams $params -UseSystemMailbox $true
Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Added $member to $($userobj.groupid) group" -Sev "Info"
$body = $results.add("Success. $member has been added")
} else {
Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "You cannot add a contact to a security group" -Sev "Error"
$body = $results.add("You cannot add a contact to a security group")
}
else {
Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "You cannot add a contact to a security group" -Sev "Error"
$body = $results.add("You cannot add a contact to a security group")
}
}
}
catch {
$body = $results.add("Failed to add member $member to $($userobj.Groupid): $($_.Exception.Message)")
}
Expand Down Expand Up @@ -149,16 +151,16 @@ if ($userobj.allowExternal -eq 'true') {

if ($userobj.sendCopies -eq 'true') {
try {
$Params = @{ Identity = $userobj.Groupid; subscriptionEnabled = $true; AutoSubscribeNewMembers = $true }
New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Set-UnifiedGroup" -cmdParams $params -useSystemMailbox $true
$Params = @{ Identity = $userobj.Groupid; subscriptionEnabled = $true; AutoSubscribeNewMembers = $true }
New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Set-UnifiedGroup" -cmdParams $params -useSystemMailbox $true

$MemberParams = @{ Identity = $userobj.Groupid; LinkType = "members" }
$Members = New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Get-UnifiedGrouplinks" -cmdParams $MemberParams
$MemberParams = @{ Identity = $userobj.Groupid; LinkType = "members" }
$Members = New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Get-UnifiedGrouplinks" -cmdParams $MemberParams

$MemberSmtpAddresses = $Members | ForEach-Object { $_.PrimarySmtpAddress }
$MemberSmtpAddresses = $Members | ForEach-Object { $_.PrimarySmtpAddress }

$subscriberParams = @{ Identity = $userobj.Groupid; LinkType = "subscribers"; Links = @($MemberSmtpAddresses) }
New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Add-UnifiedGrouplinks" -cmdParams $subscriberParams -Anchor $userobj.mail
$subscriberParams = @{ Identity = $userobj.Groupid; LinkType = "subscribers"; Links = @($MemberSmtpAddresses) }
New-ExoRequest -tenantid $Userobj.tenantid -cmdlet "Add-UnifiedGrouplinks" -cmdParams $subscriberParams -Anchor $userobj.mail


$body = $results.add("Send Copies of team emails and events to team members inboxes for $($userobj.mail) enabled.")
Expand Down
4 changes: 2 additions & 2 deletions ExecBECRemediate/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$SuspectUser" -tenantid $TenantFilter -type PATCH -body $passwordProfile -verbose
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$SuspectUser" -tenantid $TenantFilter -type PATCH -body '{"accountEnabled":"false"}' -verbose
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$SuspectUser/revokeSignInSessions" -tenantid $TenantFilter -type POST -body '{}' -verbose
$Mailboxes = New-ExoRequest -tenantid $TenantFilter -cmdlet "get-inboxrule" -cmdParams @{Mailbox = $SuspectUser } -anchor $SuspectUser | ForEach-Object {
New-ExoRequest -tenantid $TenantFilter -cmdlet "Disable-InboxRule" -cmdParams @{Confirm = $false; Identity = $_.Identity } -anchor $SuspectUser
$Mailboxes = New-ExoRequest -anchor $SuspectUser -tenantid $TenantFilter -cmdlet "get-inboxrule" -cmdParams @{Mailbox = $SuspectUser } | ForEach-Object {
New-ExoRequest -anchor $SuspectUser -tenantid $TenantFilter -cmdlet "Disable-InboxRule" -cmdParams @{Confirm = $false; Identity = $_.Identity }
}
$results = [pscustomobject]@{"Results" = "Executed Remediation for $SuspectUser and tenant $($TenantFilter). The temporary password is $password and must be changed at next logon." }
Write-LogMessage -API "BECRemediate" -tenant $tenantfilter -message "Executed Remediation for $SuspectUser" -sev "Info"
Expand Down
Loading

0 comments on commit ea085d8

Please sign in to comment.