dimanche 30 octobre 2022

Select-string patern match and notmatch

I am fairly new to Powershell and have run into a bit of a pickle.

I'm trying to find string "o_dwh" in scripts, but if there is exec before this statement like this - "exec o_dwh" - I don't want to select that. How do I do that?

So far I have this:

Get-ChildItem -Path "$packagepath\Scripts\" -Include *.txt -Recurse | Select-String -Pattern "o_dwh"

I tried this, but I know it's wrong:

Get-ChildItem -Path "$packagepath\Scripts\" -Include *.txt -Recurse | Select-String -Pattern "o_dwh" and "exec o_dwh" -notmatch

Aucun commentaire:

Enregistrer un commentaire