Operations on excel file


I have an excel file on which i need to do 2 operations:

  1. Check if the file is empty or not. I checked with this code
    if((Get-content “file.txt”) -eq $null){“File empty”}else{“File not empty”}

    and replaced an excel instead of .txt, thought the code worked for text files it dint work for excel.
  2. The data received in the excel file is sometimes old, therefore im trying to find out whether the data is correct or old by comparing it with previous sheet(the data is appended to a new sheet of the same excel file everytime). One field has the value “date” which im using to compare.

Im new to powershell please help me understand the logic.


PowerShell can access and deal with Excel files in two ways. One is using the Excel application as a COM object. Francois-Xavier Cat has a great blog post on this:


The other way is if the document is a xlsx file. This is a standardize structured data which PowerShell is great at working with. Warren Frame wrote a handy PowerShell module around it:


There is Doug Finke’s xlsx module as well: