-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCrowdstrikeDeletion.ps1
33 lines (28 loc) · 1.1 KB
/
CrowdstrikeDeletion.ps1
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
# Define the target directory and file pattern
$targetDirectory = "C:\Windows\System32\drivers\CrowdStrike"
$filePattern = "C-00000291*.sys"
# Get the list of files matching the pattern in the target directory
$files = Get-ChildItem -Path $targetDirectory -Filter $filePattern
# Initialize an array to store problematic files
$problematicFiles = @()
# Iterate through each file and check the timestamp
foreach ($file in $files) {
# Get the file's LastWriteTime
$lastWriteTimeUTC = $file.LastWriteTimeUtc
# Check if the LastWriteTime matches the problematic timestamp (04:09 UTC)
if ($lastWriteTimeUTC.Hour -eq 4 -and $lastWriteTimeUTC.Minute -eq 9) {
# Add the file to the problematic files array
$problematicFiles += $file
}
}
# Delete the problematic files
if ($problematicFiles.Count -gt 0) {
Write-Output "Deleting problematic files:"
$problematicFiles | ForEach-Object {
Write-Output "Deleting $_.FullName"
Remove-Item -Path $_.FullName -Force
}
Write-Output "Problematic files deleted."
} else {
Write-Output "No problematic files to delete."
}