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?
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.
0
SURESH0518Author Commented:
Excel format is .xslx
0
aikimarkCommented:
please post a representative sample workbook
0
ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

SURESH0518Author Commented:
Attached file
0
aikimarkCommented:
no attached file
0
SURESH0518Author Commented:
Attached File
Test.xlsx
0
aikimarkCommented:
thanks
0
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

1

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
0
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

0
aikimarkCommented:
To free up memory and resources and the interop engine.
1
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.