Parsing CPUU EMWProf log files with PowerShell

I recently got asked if there was an easier way to gather the user, computer, and status information from the EMW Client Profile Updating Utility (EMWProf) log files. Sure you can go through each log file and parse it out.  Then I thought could this be easily done in PowerShell; it turns out very easily!



I’m planning to execute the script from the directory where the EMProf log files are created. The first thing we need to do is list all log files in the directory, and create an array.

# Get list of all log files in the current directory

$Files = Get-ChildItem -filter “*.log”

# Log array

$Log =@()



Next we need find the status information from each log file that was generated.


# Find username and status from each file
Foreach ($Item in $Files)

$user = $null
Write-Host”Working on”$Item

# Get file content

# Select second last line from the file (Status line)


# Select substring
If ($LastLine-notlike”*— END LOG —*”)

$Status=”FAILED – CHECK LOG FILE “+$LastLine.Substring($LastLine.IndexOf(“[“))


elseIf ($ProfileStatus-notlike”*[Info]*”)


$Status=”FAILED – CHECK LOG FILE “+$LastLine.Substring($LastLine.IndexOf(“[“))



elseIf ($ProfileStatus.LastIndexOf(“updated”) -eq’-1′)


$Status=”FAILED – CHECK LOG FILE    ”   +$ProfileStatus.Substring($ProfileStatus.IndexOf(“[“))




$Status=”COMPLETED             ”   +$ProfileStatus.Substring($ProfileStatus.IndexOf(“[Info]”))


# Remove period at the end of the line

# Get date and time of log file

# Select 5th line from the log file (Username line)

#Select Substring


# Select 4th line from the log file (Computer line)

#Select Substring
$Computer=$Computername.Substring(($Computername.IndexOf(“: “))+2)



Finally we wanted to export this to a CSV and display it in GridView.


write-host $User – $Status – $TimeStamp – $Computer
# Add results to log
$LogObj = New-Object PSObject
$LogObj | add-member Noteproperty User       $User
$LogObj | add-member Noteproperty Workstation  $Computer
$LogObj | add-member Noteproperty Status     $Status
$LogObj | add-member Noteproperty TimeStamp  $TimeStamp
$LogObj | add-member Noteproperty LogFile    $Item.Name

$Log | Out-GridView

$Log | Export-CSV Results.csv -notype
This script will work with QMM 8.7 – 8.10 versions of Client Profile Updating Utility. However, future product releases may alter the EMWProf log file format.

Download ===>