How to compare HTML file content using powershell

Deepaklal-FT 86 Reputation points
2022-05-27T03:15:32.06+00:00

How to compare two HTML file content in powershell,
I have two URLs( actual website URL and same HTML file is stored in azure storage account), these URLs need to compare and if any changes found then I need to update my storage account with new HTML.
Uploading is working fine for me. But comparison is not happening.

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
Windows for business Windows Server User experience PowerShell
Azure Azure ISV (Independent Software Vendor) and Startups
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Steven Hodson 31 Reputation points
    2022-05-27T03:31:05.4+00:00

    You will want to do something similar to the following:

    $myVar = Compare-Object (Get-Content file1.html) (Get-Content file2.html)
    

    Then have an if-else that does the upload if the value of $myVar is not null. i.e. if it's null the files match and nothing should be done.

    1 person found this answer helpful.

  2. Rich Matheisen 47,901 Reputation points
    2023-03-02T23:52:23.6166667+00:00

    Do you care about what has changed? HTML is a structure. Are there changed in the HTML tags that matter or are you interested in the values within certain tags?

    Or are you interested in finding out, for example, that there another inconsequential space somewhere in the HTML?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.