Need help with a powershell script that modifies excel spreadsheets

Copper Contributor

I am working on a powershell script to look into a folder and pull the excel files, open them , Look at the header and footer (I know, excel doesn't have headers and footers... First and last line works) and if they match a input sting, change it to a new one. Any cases of XYZ become ABC (in the first and last line only)

I have the script doing everything I need EXCEPT that it 1). does not reconcile case (I don't want to change "xyz", just "XYZ".., tried the LookAt parameter on line 105, with no success) 2) it does change partial matches (it changes "XYZ2" to "ABC2"... Not want I wanted, and I tried the MatchCase parameter with no luck) and 3). lastly It looks beyond the first and last line... I'd prefer to just look at 1st and last but if we can't, we can't.

It looks like the $Worksheet.Columns.Replace (line 105) does not take the parameters I need, so I need another way to do that functionality.

Note, I don't have Visual studio in this environment (just notepad++), Powershell version is 5.1.17763.1007, Excel version is 16.0.4939.1000 (32bit)

Snip of the Script is attached, and any help would be appreciated.



0 Replies