Solved

How to convert MHTML file to text file using PowerShell script

Posted on 2014-01-28
3
1,254 Views
Last Modified: 2014-02-05
Is there any way to convert mhtml file to text file using powershell script?
0
Comment
Question by:SURESH0518
3 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 39816801
I guess the easiest I can think of is replacing all the html tags:
(gc file.mhtml) -replace "<.*?>" | out-file newfile.txt 

Open in new window

0
 

Author Comment

by:SURESH0518
ID: 39819077
but mhtml is Content-Transfer-Encoding: base64.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39834254
gc file.mhtml | % {
  [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_))
} | out-file textfile.txt

Open in new window

or, removing the HTML Tags as shown above
gc file.mhtml | % {
  [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_)) `
    -replace "<.*?>"
} | out-file textfile.txt

Open in new window

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS Report 2 33
Windows 10 set IP at startup 15 25
upadting roles in SQL/oracle 8 21
CSV file manipulation 6 26
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
A procedure for exporting installed hotfix details of remote computers using powershell
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now