How to compare HTML file content using powershell

Deepaklal-FT 66 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 Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,871 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,446 questions
Azure ISV (Independent Software Vendors) and Startups
Azure ISV (Independent Software Vendors) and Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.ISV (Independent Software Vendors) and Startups: A Microsoft program that helps customers adopt Microsoft Cloud solutions and drive user adoption.
91 questions
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 45,596 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