forked from winter0729/windows-driver-blacklist-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess-esd.ps1
More file actions
38 lines (30 loc) · 1.01 KB
/
Copy pathprocess-esd.ps1
File metadata and controls
38 lines (30 loc) · 1.01 KB
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
34
35
36
37
38
# process-esd.ps1
param (
[string]$WorkingDir = ".",
[string]$EsdFile = "metadata.esd"
)
$ErrorActionPreference = "Stop"
# Create directories
$outputDir = Join-Path $WorkingDir "output"
$tempDir = Join-Path $WorkingDir "temp"
New-Item -ItemType Directory -Force -Path $outputDir, $tempDir | Out-Null
$esdPath = Join-Path $tempDir $EsdFile
$targetFile = "3\Windows\System32\CodeIntegrity\driversipolicy.p7b"
try {
Write-Host "Extracting driversipolicy.p7b using 7-Zip..."
$sevenZipPath = "${env:ProgramFiles}\7-Zip\7z.exe"
if (-not (Test-Path $sevenZipPath)) {
throw "7-Zip is not installed in the default location"
}
$extractCmd = "& `"$sevenZipPath`" e `"$esdPath`" `"$targetFile`" -o`"$outputDir`" -y"
Invoke-Expression $extractCmd
if ($LASTEXITCODE -ne 0) { throw "7-Zip extraction failed" }
# Cleanup
Write-Host "Cleaning up..."
Remove-Item -Path $esdPath -Force
Write-Host "Process completed successfully!"
}
catch {
Write-Error "Error: $_"
exit 1
}