-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpdate_Store_Apps_Detection.ps1
More file actions
33 lines (31 loc) · 1021 Bytes
/
Copy pathUpdate_Store_Apps_Detection.ps1
File metadata and controls
33 lines (31 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<#
.SYNOPSIS
Detection script for a MEM Proactive Remediation.
.DESCRIPTION
The Proactive Remediation will be set to check every 7 days.
The remediation will output to a log file. So this detection on the
7th day will get the date of 5 days ago and if the log was modified
at an earlier date will return non-compliant. That way this PR
will always run weekly on machines.
.NOTES
FileName: Update_Store_Apps_Detection.ps1
Date: 24/01/2022
Author: Mark Kerry
#>
$logPath = "C:\Users\Public\Documents\IntuneDetectionLogs\StoreAppsUpdates.log"
if (Test-Path -Path $logPath) {
$logAge = (Get-ChildItem -Path $logPath).LastWriteTime
$fiveDaysAgo = (Get-Date).AddDays(-5)
if ($logAge -lt $fiveDaysAgo) {
Write-Output "Non-Compliant. Ran over 5 days ago"
exit 1
}
else {
Write-Output "Compliant. Ran less than 5 days ago"
exit 0
}
}
else {
Write-Output "Non-Compliant. StoreAppsUpdates.log does not exist"
exit 1
}