Parsing DISM Log File

by Dec 10, 2014

PowerShell 2.0 and later

In your Windows folder, you find all kinds of system log files. One is DISM.log which contains information about the configuration of Windows (feature state and more).

Here is a simple approach illustrating how you could parse this type of log file and get out rich objects that you then could process with your PowerShell cmdlets:

$path = "$env:windir\logs\dism\dism.log"

Get-Content -Path $path |
ForEach-Object {
  $_ -replace '\s{2,}', ','
} |
ConvertFrom-Csv -Header (1..20) |
ForEach-Object {
  $array = @()
  $array += $_.1 -split ' ' 
  $array += $_.2 
  $array += $_.3 
  $array += $_.4 
  $array += $_.5
  $array -join ',' 
} |
ConvertFrom-Csv -Header (1..20) |
Out-GridView

Twitter This Tip! ReTweet this Tip!