Solved

How to convert MHTML file to text file using PowerShell script

Posted on 2014-01-28
3
1,392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 70

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 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