Skip to content

Commit 4af9938

Browse files
Data-35037: Purview Audit Logging Enabled (#848)
* initial commit for spec 35037 test * updated test with correct properties * added logic to skip test in case of command failure(sharepoint cmd) * removed skip reason NoExchangeAccess
1 parent db8c3ef commit 4af9938

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Purview audit logging is the foundational mechanism for detecting and investigating data security incidents, unauthorized access attempts, and compliance violations across Microsoft 365. Without unified audit logging enabled, organizations lose visibility into who accessed sensitive data, when policy violations occurred, and what administrative actions were taken. Audit logs are critical for forensic investigations, regulatory compliance, eDiscovery, insider threat detection, and demonstrating controls to auditors and regulators. Disabling or failing to enable audit logging creates a "blind spot" where threat actors can operate undetected, policy violations go unnoticed, and incident response becomes impossible due to lack of evidence. Organizations must enable Purview audit logging to maintain visibility across Exchange Online, SharePoint Online, OneDrive, Teams, and other services, ensuring that all user and admin activities are captured and available for investigation. Without audit logging enabled, organizations cannot meet compliance requirements (SOX, HIPAA, GDPR, etc.) that mandate activity logging for sensitive operations.
2+
3+
**Remediation action**
4+
5+
To enable Purview audit logging:
6+
7+
1. Sign in as a Global Administrator or Compliance Administrator to the [Microsoft Purview portal](https://purview.microsoft.com)
8+
2. Navigate to **Audit** > **New Search**
9+
3. If prompted that auditing is not enabled, select **Turn on auditing**
10+
4. Confirm the prompt to enable unified audit logging
11+
5. Wait 1-2 hours for audit log ingestion to become active
12+
6. Via PowerShell:
13+
- Connect to Exchange Online: `Connect-ExchangeOnline`
14+
- Verify audit is enabled: `Get-AdminAuditLogConfig | Select-Object UnifiedAuditLogIngestionEnabled`
15+
- If disabled, audit logging is enabled by default for most organizations; if not, contact Microsoft Support
16+
7. Search audit logs to verify they are being collected: Navigate to **Audit** > **Audit search** and run a test search
17+
8. Configure retention policy (default is 90 days, E5 can extend to 180 days or longer with extended retention)
18+
19+
For more information:
20+
- [Enable or disable audit log search](https://learn.microsoft.com/en-us/purview/audit-log-enable-disable)
21+
- [Search the audit log](https://learn.microsoft.com/en-us/purview/audit-search)
22+
- [Audit log retention policies](https://learn.microsoft.com/en-us/purview/audit-log-retention-policies)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<#
2+
.SYNOPSIS
3+
Purview Audit Logging Enabled
4+
#>
5+
6+
function Test-Assessment-35037 {
7+
[ZtTest(
8+
Category = 'Data Security Posture Management',
9+
ImplementationCost = 'Low',
10+
MinimumLicense = ('Microsoft 365 E3'),
11+
Pillar = 'Data',
12+
RiskLevel = 'High',
13+
SfiPillar = 'Protect tenants and production systems',
14+
TenantType = ('Workforce','External'),
15+
TestId = 35037,
16+
Title = 'Purview audit logging enabled',
17+
UserImpact = 'Low'
18+
)]
19+
[CmdletBinding()]
20+
param()
21+
22+
#region Data Collection
23+
Write-PSFMessage '🟦 Start' -Tag Test -Level VeryVerbose
24+
$activity = 'Checking Purview audit logging configuration'
25+
26+
# Query Q1: Get unified audit logging configuration
27+
Write-ZtProgress -Activity $activity -Status 'Getting audit log configuration'
28+
29+
$errorMsg = $null
30+
$auditConfig = $null
31+
32+
try {
33+
$auditConfig = Get-AdminAuditLogConfig -ErrorAction Stop
34+
Write-PSFMessage "Retrieved audit log configuration" -Level Verbose
35+
}
36+
catch {
37+
$errorMsg = $_
38+
Write-PSFMessage "Error querying audit log configuration: $_" -Level Error
39+
}
40+
#endregion Data Collection
41+
42+
#region Assessment Logic
43+
if ($errorMsg -or -not $auditConfig) {
44+
Write-PSFMessage 'Not connected to Exchange Online.' -Level Warning
45+
Add-ZtTestResultDetail -SkippedBecause NotConnectedExchange
46+
return
47+
}
48+
49+
$passed = $false
50+
51+
if ($auditConfig.UnifiedAuditLogIngestionEnabled -eq $true) {
52+
$passed = $true
53+
$testResultMarkdown = "✅ Purview Audit Logging is ENABLED and all activities across Microsoft 365 services are being captured and logged for investigation and compliance purposes.`n`n%TestResult%"
54+
}
55+
else {
56+
$passed = $false
57+
$testResultMarkdown = "❌ Purview Audit Logging is DISABLED, creating a critical visibility gap where unauthorized access, policy violations, and security incidents cannot be detected or investigated.`n`n%TestResult%"
58+
}
59+
60+
#endregion Assessment Logic
61+
62+
#region Report Generation
63+
$mdInfo = ''
64+
65+
# Show audit configuration only if we have data
66+
if ($null -ne $auditConfig) {
67+
$mdInfo += "`n`n### [Audit logging status](https://purview.microsoft.com/audit)`n"
68+
$mdInfo += "| Configuration property | Value |`n"
69+
$mdInfo += "| :--- | :--- |`n"
70+
71+
$auditStatus = $auditConfig.UnifiedAuditLogIngestionEnabled
72+
$ageLimit = if ($auditConfig.AdminAuditLogAgeLimit) { $auditConfig.AdminAuditLogAgeLimit } else { 'Not configured' }
73+
$organizationId = if ($auditConfig.OrganizationId) { Get-SafeMarkdown -Text $auditConfig.OrganizationId } else { 'N/A' }
74+
75+
$mdInfo += "| Unified audit log ingestion enabled | $auditStatus |`n"
76+
$mdInfo += "| Audit log age limit | $ageLimit |`n"
77+
$mdInfo += "| Organization ID | $organizationId |"
78+
}
79+
80+
$testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $mdInfo
81+
#endregion Report Generation
82+
83+
$params = @{
84+
TestId = '35037'
85+
Title = 'Purview audit logging enabled'
86+
Status = $passed
87+
Result = $testResultMarkdown
88+
}
89+
90+
Add-ZtTestResultDetail @params
91+
}

0 commit comments

Comments
 (0)