How to search a message or sentence in an excel file using powershell script

How to search a message in a excel file using PowerShell SCript. I have excel file which has No Rows Found message and I need to get a count of this message. I would like to know how it can done in PowerShell script.

Example: if an excel file have No Rows Found message appears 5 times and I need to get count of 5.

Any help is appreciated.
SURESH0518Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
What format is/are your Excel files?

You can use a ComObject to open a workbook.
You might use a .Net library/namespace, such as VSTO.
You might use OpenSDK.
You might use a third-party tool.
SURESH0518Author Commented:
Excel format is .xslx
aikimarkCommented:
please post a representative sample workbook
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

SURESH0518Author Commented:
Attached file
aikimarkCommented:
no attached file
SURESH0518Author Commented:
Attached File
Test.xlsx
aikimarkCommented:
thanks
aikimarkCommented:
Here's the COM version of the solution.  The write-host statement produces a 4 result when invoked with your workbook.  I've renamed your workbook to Q_29098212.xlsx
$XL = new-object -comobject Excel.application
$XL.visible = $False
$wkb = $XL.workbooks.open("C:\Users\Mark\Downloads\Q_29098212.xlsx")

write-host $XL.WorksheetFunction.CountIf($wkb.ActiveSheet.UsedRange, "No Rows Found")

$wkb.close()
$XL.quit()

while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($wkb)){continue}
while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($XL)){continue}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SURESH0518Author Commented:
Thank you for your help and it worked
Senior IT System EngineerIT ProfessionalCommented:
After the .Close() and .quit(), why do you still have to perform:

while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($wkb)){continue}
while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($XL)){continue}

Open in new window

aikimarkCommented:
To free up memory and resources and the interop engine.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.