Skip to content

Commit 8587a05

Browse files
Merge pull request #1247 from kris6673/devices
New standard StaleEntraDevices and more
2 parents 8216b06 + 48867b9 commit 8587a05

File tree

114 files changed

+559
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+559
-243
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Devices/Invoke-ExecDeviceDelete.ps1

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,28 @@ Function Invoke-ExecDeviceDelete {
1111
param($Request, $TriggerMetadata)
1212

1313
$APIName = $TriggerMetadata.FunctionName
14-
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15-
16-
# Interact with query parameters or the body of the request.
14+
$ExecutingUser = $Request.headers.'x-ms-client-principal'
15+
Write-LogMessage -user $ExecutingUser -API $APINAME -message 'Accessed this API' -Sev 'Debug'
1716

17+
# Interact with body parameters or the body of the request.
18+
$TenantFilter = $Request.body.tenantFilter ?? $Request.Query.tenantFilter
19+
$Action = $Request.body.action ?? $Request.Query.action
20+
$DeviceID = $Request.body.ID ?? $Request.Query.ID
1821

1922
try {
20-
$url = "https://graph.microsoft.com/beta/devices/$($request.query.id)"
21-
if ($Request.query.action -eq 'delete') {
22-
$ActionResult = New-GraphPOSTRequest -uri $url -type DELETE -tenantid $Request.Query.TenantFilter
23-
} elseif ($Request.query.action -eq 'disable') {
24-
$ActionResult = New-GraphPOSTRequest -uri $url -type PATCH -tenantid $Request.Query.TenantFilter -body '{"accountEnabled": false }'
25-
} elseif ($Request.query.action -eq 'enable') {
26-
$ActionResult = New-GraphPOSTRequest -uri $url -type PATCH -tenantid $Request.Query.TenantFilter -body '{"accountEnabled": true }'
27-
}
28-
Write-Host $ActionResult
29-
$body = [pscustomobject]@{'Results' = "Executed action $($Request.query.action) on $($Request.query.id)" }
23+
$Results = Set-CIPPDeviceState -Action $Action -DeviceID $DeviceID -TenantFilter $TenantFilter -ExecutingUser $ExecutingUser -APIName $APINAME
24+
$StatusCode = [HttpStatusCode]::OK
3025
} catch {
31-
$body = [pscustomobject]@{'Results' = "Failed to queue action $($Request.query.action) on $($request.query.id): $($_.Exception.Message)" }
26+
$Results = $_.Exception.Message
27+
$StatusCode = [HttpStatusCode]::BadRequest
3228
}
3329

30+
Write-Host $Results
31+
$body = [pscustomobject]@{'Results' = "$Results" }
32+
3433
# Associate values to output bindings by calling 'Push-OutputBinding'.
3534
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
36-
StatusCode = [HttpStatusCode]::OK
35+
StatusCode = $StatusCode
3736
Body = $body
3837
})
3938

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
function Set-CIPPDeviceState {
2+
<#
3+
.SYNOPSIS
4+
Sets or modifies the state of a device in Microsoft Graph.
5+
6+
.DESCRIPTION
7+
This function allows you to enable, disable, or delete a device by making
8+
corresponding requests to the Microsoft Graph API. It logs the result
9+
and returns a success or error message based on the outcome.
10+
11+
.PARAMETER Action
12+
Specifies the action to perform on the device. Valid actions are:
13+
- Enable: Enable the device
14+
- Disable: Disable the device
15+
- Delete: Remove the device from the tenant
16+
17+
.PARAMETER DeviceID
18+
Specifies the unique identifier (Object ID) of the device to be managed.
19+
20+
.PARAMETER TenantFilter
21+
Specifies the tenant ID or domain against which to perform the operation.
22+
23+
.PARAMETER ExecutingUser
24+
Specifies the user who initiated the request for logging purposes.
25+
26+
.PARAMETER APIName
27+
Specifies the name of the API call for logging purposes. Defaults to 'Set Device State'.
28+
29+
.EXAMPLE
30+
Set-CIPPDeviceState -Action Enable -DeviceID "1234abcd-5678-efgh-ijkl-9012mnopqrst" -TenantFilter "contoso.onmicrosoft.com" -ExecutingUser "[email protected]"
31+
32+
This command enables the specified device within the given tenant.
33+
34+
.EXAMPLE
35+
Set-CIPPDeviceState -Action Delete -DeviceID "1234abcd-5678-efgh-ijkl-9012mnopqrst" -TenantFilter "contoso.onmicrosoft.com"
36+
37+
This command removes the specified device from the tenant.
38+
#>
39+
param (
40+
[Parameter(Mandatory = $true)][ValidateSet('Enable', 'Disable', 'Delete')]$Action,
41+
42+
[ValidateScript({
43+
if ([Guid]::TryParse($_, [ref] [Guid]::Empty)) {
44+
$true
45+
} else {
46+
throw 'DeviceID must be a valid GUID.'
47+
}
48+
})]
49+
[Parameter(Mandatory = $true)]$DeviceID,
50+
51+
[Parameter(Mandatory = $true)]$TenantFilter,
52+
$ExecutingUser,
53+
$APIName = 'Set Device State'
54+
)
55+
$Url = "https://graph.microsoft.com/beta/devices/$($DeviceID)"
56+
57+
try {
58+
switch ($Action) {
59+
'Delete' {
60+
$ActionResult = New-GraphPOSTRequest -uri $Url -type DELETE -tenantid $TenantFilter
61+
}
62+
'Disable' {
63+
$ActionResult = New-GraphPOSTRequest -uri $Url -type PATCH -tenantid $TenantFilter -body '{"accountEnabled": false }'
64+
}
65+
'Enable' {
66+
$ActionResult = New-GraphPOSTRequest -uri $Url -type PATCH -tenantid $TenantFilter -body '{"accountEnabled": true }'
67+
}
68+
}
69+
Write-Host $ActionResult
70+
Write-LogMessage -user $ExecutingUser -API $APIName -message "Executed action $($Action) on $($DeviceID)" -Sev Info
71+
return "Executed action $($Action) on $($DeviceID)"
72+
} catch {
73+
$ErrorMessage = Get-CippException -Exception $_
74+
Write-LogMessage -user $ExecutingUser -API $APIName -message "Failed to queue action $($Action) on $($DeviceID). Error: $($ErrorMessage.NormalizedError)" -Sev Error -LogData $ErrorMessage
75+
throw "Failed to queue action $($Action) on $($DeviceID). Error: $($ErrorMessage.NormalizedError)"
76+
}
77+
78+
79+
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardActivityBasedTimeout.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Invoke-CIPPStandardActivityBasedTimeout {
1717
"CIS"
1818
"spo_idle_session_timeout"
1919
ADDEDCOMPONENT
20-
{"type":"Select","label":"Select value","name":"standards.ActivityBasedTimeout.timeout","values":[{"label":"1 Hour","value":"01:00:00"},{"label":"3 Hours","value":"03:00:00"},{"label":"6 Hours","value":"06:00:00"},{"label":"12 Hours","value":"12:00:00"},{"label":"24 Hours","value":"1.00:00:00"}]}
20+
{"type":"select","multiple":false,"label":"Select value","name":"standards.ActivityBasedTimeout.timeout","options":[{"label":"1 Hour","value":"01:00:00"},{"label":"3 Hours","value":"03:00:00"},{"label":"6 Hours","value":"06:00:00"},{"label":"12 Hours","value":"12:00:00"},{"label":"24 Hours","value":"1.00:00:00"}]}
2121
IMPACT
2222
Medium Impact
2323
POWERSHELLEQUIVALENT
@@ -27,7 +27,7 @@ function Invoke-CIPPStandardActivityBasedTimeout {
2727
UPDATECOMMENTBLOCK
2828
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2929
.LINK
30-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
30+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/global-standards#medium-impact
3131
#>
3232

3333
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAddDKIM.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Invoke-CIPPStandardAddDKIM {
2525
UPDATECOMMENTBLOCK
2626
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2727
.LINK
28-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
28+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/exchange-standards#low-impact
2929
#>
3030

3131
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAnonReportDisable.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Invoke-CIPPStandardAnonReportDisable {
2323
UPDATECOMMENTBLOCK
2424
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2525
.LINK
26-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
26+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/global-standards#low-impact
2727
#>
2828

2929
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAntiPhishPolicy.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ function Invoke-CIPPStandardAntiPhishPolicy {
2424
"mdo_phishthresholdlevel"
2525
ADDEDCOMPONENT
2626
{"type":"number","label":"Phishing email threshold. (Default 1)","name":"standards.AntiPhishPolicy.PhishThresholdLevel","default":1}
27-
{"type":"boolean","label":"Show first contact safety tip","name":"standards.AntiPhishPolicy.EnableFirstContactSafetyTips","default":true}
28-
{"type":"boolean","label":"Show user impersonation safety tip","name":"standards.AntiPhishPolicy.EnableSimilarUsersSafetyTips","default":true}
29-
{"type":"boolean","label":"Show domain impersonation safety tip","name":"standards.AntiPhishPolicy.EnableSimilarDomainsSafetyTips","default":true}
30-
{"type":"boolean","label":"Show user impersonation unusual characters safety tip","name":"standards.AntiPhishPolicy.EnableUnusualCharactersSafetyTips","default":true}
31-
{"type":"Select","label":"If the message is detected as spoof by spoof intelligence","name":"standards.AntiPhishPolicy.AuthenticationFailAction","values":[{"label":"Quarantine the message","value":"Quarantine"},{"label":"Move to Junk Folder","value":"MoveToJmf"}]}
32-
{"type":"Select","label":"Quarantine policy for Spoof","name":"standards.AntiPhishPolicy.SpoofQuarantineTag","values":[{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"},{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"}]}
33-
{"type":"Select","label":"If a message is detected as user impersonation","name":"standards.AntiPhishPolicy.TargetedUserProtectionAction","values":[{"label":"Move to Junk Folder","value":"MoveToJmf"},{"label":"Delete the message before its delivered","value":"Delete"},{"label":"Quarantine the message","value":"Quarantine"}]}
34-
{"type":"Select","label":"Quarantine policy for user impersonation","name":"standards.AntiPhishPolicy.TargetedUserQuarantineTag","values":[{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"},{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"}]}
35-
{"type":"Select","label":"If a message is detected as domain impersonation","name":"standards.AntiPhishPolicy.TargetedDomainProtectionAction","values":[{"label":"Move to Junk Folder","value":"MoveToJmf"},{"label":"Delete the message before its delivered","value":"Delete"},{"label":"Quarantine the message","value":"Quarantine"}]}
36-
{"type":"Select","label":"Quarantine policy for domain impersonation","name":"standards.AntiPhishPolicy.TargetedDomainQuarantineTag","values":[{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"},{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"}]}
37-
{"type":"Select","label":"If Mailbox Intelligence detects an impersonated user","name":"standards.AntiPhishPolicy.MailboxIntelligenceProtectionAction","values":[{"label":"Move to Junk Folder","value":"MoveToJmf"},{"label":"Delete the message before its delivered","value":"Delete"},{"label":"Quarantine the message","value":"Quarantine"}]}
38-
{"type":"Select","label":"Apply quarantine policy","name":"standards.AntiPhishPolicy.MailboxIntelligenceQuarantineTag","values":[{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"},{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"}]}
27+
{"type":"switch","label":"Show first contact safety tip","name":"standards.AntiPhishPolicy.EnableFirstContactSafetyTips","default":true}
28+
{"type":"switch","label":"Show user impersonation safety tip","name":"standards.AntiPhishPolicy.EnableSimilarUsersSafetyTips","default":true}
29+
{"type":"switch","label":"Show domain impersonation safety tip","name":"standards.AntiPhishPolicy.EnableSimilarDomainsSafetyTips","default":true}
30+
{"type":"switch","label":"Show user impersonation unusual characters safety tip","name":"standards.AntiPhishPolicy.EnableUnusualCharactersSafetyTips","default":true}
31+
{"type":"select","multiple":false,"label":"If the message is detected as spoof by spoof intelligence","name":"standards.AntiPhishPolicy.AuthenticationFailAction","options":[{"label":"Quarantine the message","value":"Quarantine"},{"label":"Move to Junk Folder","value":"MoveToJmf"}]}
32+
{"type":"select","multiple":false,"label":"Quarantine policy for Spoof","name":"standards.AntiPhishPolicy.SpoofQuarantineTag","options":[{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"},{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"}]}
33+
{"type":"select","multiple":false,"label":"If a message is detected as user impersonation","name":"standards.AntiPhishPolicy.TargetedUserProtectionAction","options":[{"label":"Move to Junk Folder","value":"MoveToJmf"},{"label":"Delete the message before its delivered","value":"Delete"},{"label":"Quarantine the message","value":"Quarantine"}]}
34+
{"type":"select","multiple":false,"label":"Quarantine policy for user impersonation","name":"standards.AntiPhishPolicy.TargetedUserQuarantineTag","options":[{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"},{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"}]}
35+
{"type":"select","multiple":false,"label":"If a message is detected as domain impersonation","name":"standards.AntiPhishPolicy.TargetedDomainProtectionAction","options":[{"label":"Move to Junk Folder","value":"MoveToJmf"},{"label":"Delete the message before its delivered","value":"Delete"},{"label":"Quarantine the message","value":"Quarantine"}]}
36+
{"type":"select","multiple":false,"label":"Quarantine policy for domain impersonation","name":"standards.AntiPhishPolicy.TargetedDomainQuarantineTag","options":[{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"},{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"}]}
37+
{"type":"select","multiple":false,"label":"If Mailbox Intelligence detects an impersonated user","name":"standards.AntiPhishPolicy.MailboxIntelligenceProtectionAction","options":[{"label":"Move to Junk Folder","value":"MoveToJmf"},{"label":"Delete the message before its delivered","value":"Delete"},{"label":"Quarantine the message","value":"Quarantine"}]}
38+
{"type":"select","multiple":false,"label":"Apply quarantine policy","name":"standards.AntiPhishPolicy.MailboxIntelligenceQuarantineTag","options":[{"label":"AdminOnlyAccessPolicy","value":"AdminOnlyAccessPolicy"},{"label":"DefaultFullAccessPolicy","value":"DefaultFullAccessPolicy"},{"label":"DefaultFullAccessWithNotificationPolicy","value":"DefaultFullAccessWithNotificationPolicy"}]}
3939
IMPACT
4040
Low Impact
4141
POWERSHELLEQUIVALENT
@@ -45,7 +45,7 @@ function Invoke-CIPPStandardAntiPhishPolicy {
4545
UPDATECOMMENTBLOCK
4646
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
4747
.LINK
48-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
48+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/defender-standards#low-impact
4949
#>
5050

5151
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAppDeploy.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Invoke-CIPPStandardAppDeploy {
1515
TAG
1616
"lowimpact"
1717
ADDEDCOMPONENT
18-
{"type":"input","name":"standards.AppDeploy.appids","label":"Application IDs, comma separated"}
18+
{"type":"textField","name":"standards.AppDeploy.appids","label":"Application IDs, comma separated"}
1919
IMPACT
2020
Low Impact
2121
POWERSHELLEQUIVALENT
@@ -24,7 +24,7 @@ function Invoke-CIPPStandardAppDeploy {
2424
UPDATECOMMENTBLOCK
2525
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2626
.LINK
27-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
27+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/entra-aad-standards#low-impact
2828
#>
2929

3030
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAtpPolicyForO365.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ function Invoke-CIPPStandardAtpPolicyForO365 {
77
.SYNOPSIS
88
(Label) Default Atp Policy For O365
99
.DESCRIPTION
10-
(Helptext) This creates a Atp policy that enables Defender for Office 365 for Sharepoint, OneDrive and Microsoft Teams.
11-
(DocsDescription) This creates a Atp policy that enables Defender for Office 365 for Sharepoint, OneDrive and Microsoft Teams.
10+
(Helptext) This creates a Atp policy that enables Defender for Office 365 for SharePoint, OneDrive and Microsoft Teams.
11+
(DocsDescription) This creates a Atp policy that enables Defender for Office 365 for SharePoint, OneDrive and Microsoft Teams.
1212
.NOTES
1313
CAT
1414
Defender Standards
1515
TAG
1616
"lowimpact"
1717
"CIS"
1818
ADDEDCOMPONENT
19-
{"type":"boolean","label":"Allow people to click through Protected View even if Safe Documents identified the file as malicious","name":"standards.AtpPolicyForO365.AllowSafeDocsOpen","default":false}
19+
{"type":"switch","label":"Allow people to click through Protected View even if Safe Documents identified the file as malicious","name":"standards.AtpPolicyForO365.AllowSafeDocsOpen","default":false,"required":false}
2020
IMPACT
2121
Low Impact
2222
POWERSHELLEQUIVALENT
@@ -26,7 +26,7 @@ function Invoke-CIPPStandardAtpPolicyForO365 {
2626
UPDATECOMMENTBLOCK
2727
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2828
.LINK
29-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
29+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/defender-standards#low-impact
3030
#>
3131

3232
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAuditLog.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Invoke-CIPPStandardAuditLog {
2626
UPDATECOMMENTBLOCK
2727
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2828
.LINK
29-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
29+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/global-standards#low-impact
3030
#>
3131

3232
param($Tenant, $Settings)

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAutoExpandArchive.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Invoke-CIPPStandardAutoExpandArchive {
2323
UPDATECOMMENTBLOCK
2424
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
2525
.LINK
26-
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
26+
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/exchange-standards#low-impact
2727
#>
2828

2929
param($Tenant, $Settings)

0 commit comments

Comments
 (0)