Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c7216ab
Add or update the Azure App Service build and deployment workflow config
KelvinTegelaar Aug 23, 2024
0ebfe1e
Merge pull request #1101 from KelvinTegelaar/dev
KelvinTegelaar Aug 30, 2024
a40d992
Delete .github/workflows/master_cippwuxwa.yml
KelvinTegelaar Aug 30, 2024
73d8b96
Merge pull request #1103 from KelvinTegelaar/dev
JohnDuprey Aug 30, 2024
669d084
Merge pull request #1138 from KelvinTegelaar/dev
KelvinTegelaar Oct 4, 2024
ca40bab
Merge pull request #1151 from KelvinTegelaar/dev
JohnDuprey Oct 11, 2024
720ce15
Merge pull request #1153 from KelvinTegelaar/dev
JohnDuprey Oct 12, 2024
2b471b9
Merge pull request #1181 from KelvinTegelaar/dev
JohnDuprey Nov 13, 2024
a352c4c
Merge pull request #1195 from KelvinTegelaar/dev
JohnDuprey Dec 3, 2024
7fb54de
Update Connect-HuduAPI.ps1
Teh-STIG Dec 26, 2024
70c9d60
Update Connect-HuduAPI.ps1
Teh-STIG Dec 26, 2024
d6c4f1f
Add or update the Azure App Service build and deployment workflow config
KelvinTegelaar Jan 10, 2025
7211adc
Remove the Azure App Service build and deployment workflow config
KelvinTegelaar Jan 10, 2025
ad595b6
Merge pull request #1208 from KelvinTegelaar/dev
KelvinTegelaar Jan 10, 2025
e44881d
Merge pull request #1209 from KelvinTegelaar/interface-rewrite
JohnDuprey Jan 10, 2025
3bca2ce
Merge pull request #1211 from KelvinTegelaar/dev
JohnDuprey Jan 10, 2025
99c417b
Merge pull request #1217 from KelvinTegelaar/dev
KelvinTegelaar Jan 13, 2025
17f65df
Merge pull request #1223 from KelvinTegelaar/dev
KelvinTegelaar Jan 14, 2025
98f7f61
Merge pull request #1231 from KelvinTegelaar/dev
KelvinTegelaar Jan 16, 2025
fd6c112
Merge pull request #1232 from KelvinTegelaar/dev
KelvinTegelaar Jan 16, 2025
5b3da6f
Skip disabled users and enhance readability
kris6673 Jan 17, 2025
9ff3bf0
formatting
kris6673 Jan 17, 2025
8789480
Merge pull request #1240 from KelvinTegelaar/dev
KelvinTegelaar Jan 17, 2025
4c54958
Filter inactive licensed users based on account status
kris6673 Jan 17, 2025
f60a80f
Merge branch 'dev' of https://github.com/kris6673/CIPP-API into exclu…
kris6673 Jan 17, 2025
d79657c
fix
kris6673 Jan 17, 2025
edbe8d2
comment
kris6673 Jan 17, 2025
59c29ef
improve logging
kris6673 Jan 18, 2025
39cabcd
param capitalization
kris6673 Jan 18, 2025
cb1a622
Improve error handling in Invoke-CIPPStandardEnablePronouns function
kris6673 Jan 18, 2025
a5f98e2
Add new standard: ProfilePhotos
kris6673 Jan 18, 2025
d1f548b
move comment
kris6673 Jan 18, 2025
cba3c55
Add a comment explaining the current limitation with the API endpoint…
kris6673 Jan 18, 2025
618a0ba
FIX DelegateSentItems to actually do what it says in the frontend and…
kris6673 Jan 18, 2025
eda26a7
Support POST and GET request for ExecHideFromGAL
kris6673 Jan 19, 2025
06210fe
Add Invoke-ListGlobalAddressList function for retrieving global addre…
kris6673 Jan 19, 2025
c8e3669
Add Set-CIPPDeviceState function and refactor Invoke-ExecDeviceDelete…
kris6673 Jan 19, 2025
0c4cd30
Add Invoke-CIPPStandardStaleEntraDevices function to identify and rep…
kris6673 Jan 19, 2025
accc549
Remove comment
kris6673 Jan 19, 2025
c67404d
Better links to docs in the help
kris6673 Jan 19, 2025
1cd4dd9
Update documentation links in standards scripts to point to the corre…
kris6673 Jan 19, 2025
48867b9
Enhance Invoke-ExecDeviceDelete to support tenantFilter and action fr…
kris6673 Jan 19, 2025
9f20219
Merge pull request #1243 from kris6673/photo-change
KelvinTegelaar Jan 19, 2025
b9cfa1e
Merge pull request #1244 from kris6673/DelegateSentItems
KelvinTegelaar Jan 19, 2025
9ee4bd7
Merge pull request #1242 from kris6673/calDefaults-logging
KelvinTegelaar Jan 19, 2025
aa425b2
Use tertiary operator instead to improve readability
kris6673 Jan 19, 2025
8216b06
Merge pull request #1245 from kris6673/gal
KelvinTegelaar Jan 19, 2025
8587a05
Merge pull request #1247 from kris6673/devices
KelvinTegelaar Jan 19, 2025
60f52e4
Merge branch 'dev' into exclude-disabled-users
KelvinTegelaar Jan 19, 2025
2c5d178
Merge pull request #1241 from kris6673/exclude-disabled-users
KelvinTegelaar Jan 19, 2025
4c28907
Sort Intune Templates regardless of View
nichxlxs Jan 19, 2025
0d0dbc6
Merge pull request #1248 from nichxlxs/patch-1
KelvinTegelaar Jan 19, 2025
0ad13cd
Merge pull request #1199 from Teh-STIG/dev
KelvinTegelaar Jan 19, 2025
951cd47
backup fixes
KelvinTegelaar Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ function Get-CIPPAlertInactiveLicensedUsers {
try {

$Lookup = (Get-Date).AddDays(-90).ToUniversalTime().ToString('o')
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users?`$filter=(signInActivity/lastNonInteractiveSignInDateTime le $Lookup)&`$select=id,UserPrincipalName,signInActivity,mail,userType,accountEnabled,assignedLicenses" -scope 'https://graph.microsoft.com/.default' -tenantid $TenantFilter | Where-Object { $_.assignedLicenses.skuId -ne $null }
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users?`$filter=(signInActivity/lastNonInteractiveSignInDateTime le $Lookup)&`$select=id,UserPrincipalName,signInActivity,mail,userType,accountEnabled,assignedLicenses" -scope 'https://graph.microsoft.com/.default' -tenantid $TenantFilter |
Where-Object { $null -ne $_.assignedLicenses.skuId }

# true = only active users
if ($InputValue -eq $true) { $GraphRequest = $GraphRequest | Where-Object { $_.accountEnabled -eq $true } }
$AlertData = foreach ($user in $GraphRequest) {
$Message = 'User {0} has been inactive for 90 days, but still has a license assigned.' -f $user.UserPrincipalName
$user | Select-Object -Property userPrincipalname, signInActivity, @{Name = 'Message'; Expression = { $Message } }
$user | Select-Object -Property UserPrincipalName, signInActivity, @{Name = 'Message'; Expression = { $Message } }

}
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,30 @@ Function Invoke-ExecHideFromGAL {
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$ExecutingUser = $Request.headers.'x-ms-client-principal'
$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $ExecutingUser -API $APINAME -message 'Accessed this API' -Sev 'Debug'


# Support if the request is a POST or a GET. So to support legacy(GET) and new(POST) requests
$UserId = $Request.Query.ID ?? $Request.body.ID
$TenantFilter = $Request.Query.TenantFilter ?? $Request.body.tenantFilter
$Hidden = -not [string]::IsNullOrWhiteSpace($Request.Query.HideFromGAL) ? [System.Convert]::ToBoolean($Request.Query.HideFromGAL) : [System.Convert]::ToBoolean($Request.body.HideFromGAL)


$TenantFilter = $request.query.tenantfilter
Try {
$Hidden = [System.Convert]::ToBoolean($Request.query.HideFromGal)
$HideResults = Set-CIPPHideFromGAL -tenantFilter $tenantFilter -userid $Request.query.ID -HideFromGAL $Hidden -ExecutingUser $request.headers.'x-ms-client-principal' -APIName 'ExecOffboardUser'
$HideResults = Set-CIPPHideFromGAL -tenantFilter $TenantFilter -UserID $UserId -hidefromgal $Hidden -ExecutingUser $ExecutingUser -APIName $APIName
$Results = [pscustomobject]@{'Results' = $HideResults }
$StatusCode = [HttpStatusCode]::OK

} catch {
$Results = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Hide/UnHide from GAL failed: $($_.Exception.Message)" -Sev 'Error'
$ErrorMessage = Get-CippException -Exception $_
$Results = [pscustomobject]@{'Results' = "Failed. $($ErrorMessage.NormalizedError)" }
$StatusCode = [HttpStatusCode]::Forbidden
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
StatusCode = $StatusCode
Body = $Results
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using namespace System.Net

Function Invoke-ListGlobalAddressList {
<#
.FUNCTIONALITY
Entrypoint
.ROLE
Exchange.Mailbox.Read
#>
[CmdletBinding()]
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
$ExecutingUser = $Request.headers.'x-ms-client-principal'
Write-LogMessage -user $ExecutingUser -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$TenantFilter = $Request.Query.tenantFilter

try {
$GAL = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Recipient' -cmdParams @{ResultSize = 'unlimited'; SortBy = 'DisplayName' } `
-Select 'Identity, DisplayName, Alias, PrimarySmtpAddress, ExternalDirectoryObjectId, HiddenFromAddressListsEnabled, EmailAddresses, IsDirSynced, SKUAssigned, RecipientType, RecipientTypeDetails, AddressListMembership' | Select-Object -ExcludeProperty *odata*, *data.type*
$StatusCode = [HttpStatusCode]::OK
} catch {
$ErrorMessage = Get-CippException -Exception $_
$StatusCode = [HttpStatusCode]::Forbidden
$GAL = $ErrorMessage.NormalizedError
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = $StatusCode
Body = @($GAL)
})

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,28 @@ Function Invoke-ExecDeviceDelete {
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'

# Interact with query parameters or the body of the request.
$ExecutingUser = $Request.headers.'x-ms-client-principal'
Write-LogMessage -user $ExecutingUser -API $APINAME -message 'Accessed this API' -Sev 'Debug'

# Interact with body parameters or the body of the request.
$TenantFilter = $Request.body.tenantFilter ?? $Request.Query.tenantFilter
$Action = $Request.body.action ?? $Request.Query.action
$DeviceID = $Request.body.ID ?? $Request.Query.ID

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

Write-Host $Results
$body = [pscustomobject]@{'Results' = "$Results" }

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
StatusCode = $StatusCode
Body = $body
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Function Invoke-ListIntuneTemplates {

if ($Request.query.ID) { $Templates = $Templates | Where-Object -Property guid -EQ $Request.query.id }

# Sort all output regardless of view condition
$Templates = $Templates | Sort-Object -Property displayName

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
Expand Down
2 changes: 2 additions & 0 deletions Modules/CIPPCore/Public/New-CIPPBackup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function New-CIPPBackup {
'standards'
'SchedulerConfig'
'Extensions'
'WebhookRules'
'ScheduledTasks'
)
$CSVfile = foreach ($CSVTable in $BackupTables) {
$Table = Get-CippTable -tablename $CSVTable
Expand Down
79 changes: 79 additions & 0 deletions Modules/CIPPCore/Public/Set-CIPPDeviceState.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function Set-CIPPDeviceState {
<#
.SYNOPSIS
Sets or modifies the state of a device in Microsoft Graph.

.DESCRIPTION
This function allows you to enable, disable, or delete a device by making
corresponding requests to the Microsoft Graph API. It logs the result
and returns a success or error message based on the outcome.

.PARAMETER Action
Specifies the action to perform on the device. Valid actions are:
- Enable: Enable the device
- Disable: Disable the device
- Delete: Remove the device from the tenant

.PARAMETER DeviceID
Specifies the unique identifier (Object ID) of the device to be managed.

.PARAMETER TenantFilter
Specifies the tenant ID or domain against which to perform the operation.

.PARAMETER ExecutingUser
Specifies the user who initiated the request for logging purposes.

.PARAMETER APIName
Specifies the name of the API call for logging purposes. Defaults to 'Set Device State'.

.EXAMPLE
Set-CIPPDeviceState -Action Enable -DeviceID "1234abcd-5678-efgh-ijkl-9012mnopqrst" -TenantFilter "contoso.onmicrosoft.com" -ExecutingUser "admin@contoso.onmicrosoft.com"

This command enables the specified device within the given tenant.

.EXAMPLE
Set-CIPPDeviceState -Action Delete -DeviceID "1234abcd-5678-efgh-ijkl-9012mnopqrst" -TenantFilter "contoso.onmicrosoft.com"

This command removes the specified device from the tenant.
#>
param (
[Parameter(Mandatory = $true)][ValidateSet('Enable', 'Disable', 'Delete')]$Action,

[ValidateScript({
if ([Guid]::TryParse($_, [ref] [Guid]::Empty)) {
$true
} else {
throw 'DeviceID must be a valid GUID.'
}
})]
[Parameter(Mandatory = $true)]$DeviceID,

[Parameter(Mandatory = $true)]$TenantFilter,
$ExecutingUser,
$APIName = 'Set Device State'
)
$Url = "https://graph.microsoft.com/beta/devices/$($DeviceID)"

try {
switch ($Action) {
'Delete' {
$ActionResult = New-GraphPOSTRequest -uri $Url -type DELETE -tenantid $TenantFilter
}
'Disable' {
$ActionResult = New-GraphPOSTRequest -uri $Url -type PATCH -tenantid $TenantFilter -body '{"accountEnabled": false }'
}
'Enable' {
$ActionResult = New-GraphPOSTRequest -uri $Url -type PATCH -tenantid $TenantFilter -body '{"accountEnabled": true }'
}
}
Write-Host $ActionResult
Write-LogMessage -user $ExecutingUser -API $APIName -message "Executed action $($Action) on $($DeviceID)" -Sev Info
return "Executed action $($Action) on $($DeviceID)"
} catch {
$ErrorMessage = Get-CippException -Exception $_
Write-LogMessage -user $ExecutingUser -API $APIName -message "Failed to queue action $($Action) on $($DeviceID). Error: $($ErrorMessage.NormalizedError)" -Sev Error -LogData $ErrorMessage
throw "Failed to queue action $($Action) on $($DeviceID). Error: $($ErrorMessage.NormalizedError)"
}


}
14 changes: 7 additions & 7 deletions Modules/CIPPCore/Public/Set-CIPPHideFromGAL.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
function Set-CIPPHideFromGAL {
[CmdletBinding()]
param (
$userid,
$tenantFilter,
$UserId,
$TenantFilter,
$APIName = 'Hide From Address List',
[bool]$HideFromGAL,
$ExecutingUser
)
$Text = if ($HideFromGAL) { 'hidden' } else { 'unhidden' }
try {
$null = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Set-mailbox' -cmdParams @{Identity = $userid ; HiddenFromAddressListsEnabled = $HideFromGAL }
Write-LogMessage -user $ExecutingUser -API $APINAME -tenant $($tenantfilter) -message "$($userid) $Text from GAL" -Sev 'Info'
return "Successfully $Text $($userid) from GAL."
$null = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Set-Mailbox' -cmdParams @{Identity = $UserId ; HiddenFromAddressListsEnabled = $HideFromGAL }
Write-LogMessage -user $ExecutingUser -API $APINAME -tenant $($Tenantfilter) -message "$($UserId) $Text from GAL" -Sev Info
return "Successfully $Text $($UserId) from GAL."
} catch {
$ErrorMessage = Get-CippException -Exception $_
Write-LogMessage -user $ExecutingUser -API $APIName -message "Could not hide $($userid) from address list. Error: $($ErrorMessage.NormalizedError)" -Sev 'Error' -tenant $TenantFilter -LogData $ErrorMessage
return "Could not hide $($userid) from address list. Error: $($ErrorMessage.NormalizedError)"
Write-LogMessage -user $ExecutingUser -API $APIName -message "Could not hide $($UserId) from address list. Error: $($ErrorMessage.NormalizedError)" -Sev 'Error' -tenant $TenantFilter -LogData $ErrorMessage
return "Could not hide $($UserId) from address list. Error: $($ErrorMessage.NormalizedError)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Invoke-CIPPStandardActivityBasedTimeout {
"CIS"
"spo_idle_session_timeout"
ADDEDCOMPONENT
{"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"}]}
{"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"}]}
IMPACT
Medium Impact
POWERSHELLEQUIVALENT
Expand All @@ -27,7 +27,7 @@ function Invoke-CIPPStandardActivityBasedTimeout {
UPDATECOMMENTBLOCK
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
.LINK
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/global-standards#medium-impact
#>

param($Tenant, $Settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Invoke-CIPPStandardAddDKIM {
UPDATECOMMENTBLOCK
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
.LINK
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/exchange-standards#low-impact
#>

param($Tenant, $Settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Invoke-CIPPStandardAnonReportDisable {
UPDATECOMMENTBLOCK
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
.LINK
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
https://docs.cipp.app/user-documentation/tenant/standards/list-standards/global-standards#low-impact
#>

param($Tenant, $Settings)
Expand Down
Loading