Tuesday, February 12, 2013 2:59 AM
Hey Scripting Guy!
This is a basic question, but has me stumped. I have trawled the web for the uses of 'select-string' and everywhere says I can use it to search for text in: .doc, .xls, .ppt, .txt etc. Now I can get it to work no probs with .doc files, but when I point it at .ppt files I get no results...??? Below is a basic version of what im trying to acheive. I dummed it down to see if it would work in its basic form and no joy...what am I doing wrong?! The target powerpoint file has a slide with the word alpha as a title. Help Pls!
# PowerShell cmdlet to find the word "alpha".
$Location = "c:\scripts\testppt1.ppt"
$SearchStr = "alpha"
$Sel = Select-String -pattern $SearchStr -path $Location
If ($Sel -eq $null)
write-host "$Location does not contain $SearchStr"
write-host "Found `n$Sel"
Tuesday, February 12, 2013 3:10 AM
Typical...I spend all that time trying to figure it out and the moment I post on here I figure out what the issue is!
I forgot that I renamed a .pptx file to .ppt (a test file) and that seems to be causing the issue. I created a new file from scratch in .ppt format and select-string works.
- Marked As Answer by Thomas LeeMVP, Moderator Tuesday, February 12, 2013 12:06 PM
Tuesday, February 12, 2013 7:34 AM
If you want to search for text inside a .docx, .xlsx or .pptx - I would suggest you look at the project Power Tools for Open XML over at Codeplex
Their Select-OpenXMLString command has similar functionality for OOXML documents:
- Edited by Claus Codam Tuesday, February 12, 2013 7:37 AM grammar