How to convert MHTML file to text file using PowerShell script

Is there any way to convert mhtml file to text file using powershell script?
SURESH0518Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
QlemoConnect With a Mentor DeveloperCommented:
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
 
becraigCommented:
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
 
SURESH0518Author Commented:
but mhtml is Content-Transfer-Encoding: base64.
0
All Courses

From novice to tech pro — start learning today.