[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to convert MHTML file to text file using PowerShell script

Posted on 2014-01-28
3
Medium Priority
?
1,523 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 71

Accepted Solution

by:
Qlemo earned 2000 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

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

650 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