Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
7
Indexable
Never
$BaselinePath = "C:\Baseline"

$BaselineFilePath = Join-Path -Path $BaselinePath -ChildPath "ConfigurationBaseline.txt"

if (-not (Test-Path -Path $BaselinePath)) {
    New-Item -ItemType Directory -Path $BaselinePath | Out-Null
}

$FileList = @(
    "C:\Windows\ntoskrnl.exe",
    "C:\Windows\explorer.exe",
    "C:\Windows\win.ini",
    "C:\Windows\System32\kernel32.dll",
    "C:\Windows\System32\services.exe",
    "C:\Windows\System32\svchost.exe"
)

$BaselineData = @{}

foreach ($FilePath in $FileList) {
    if (Test-Path -Path $FilePath -PathType Leaf) {
        $FileInfo = Get-Item -Path $FilePath
        $FileProperties = @{
            "Name"           = $FileInfo.Name
            "Path"           = $FileInfo.FullName
            "Size"           = $FileInfo.Length
            "LastWriteTime"  = $FileInfo.LastWriteTime
        }
        $BaselineData[$FilePath] = $FileProperties
    }
}

$BaselineData | ConvertTo-Json | Out-File -FilePath $BaselineFilePath

Write-Host "Configuration baseline file created successfully. Baseline file saved at: $BaselineFilePath"
Leave a Comment