Created
March 27, 2015 13:12
-
-
Save chelnak/63134529862128a35cec to your computer and use it in GitHub Desktop.
Search for a string in multiple files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Needed to search for invalid hostname inside lots of config files | |
| $wrongHost = "the-host.com" | |
| $path = "D:\Program Files (x86)\VMware\vCAC\" | |
| Get-ChildItem -Path $path -Filter *.config -Recurse | ? { !$_.PSIsContainer } | % { | |
| $f = Get-Content $_.FullName | |
| $c = $f | % { $_ -match $wrongHost } | |
| if ($c -contains $true) | |
| { | |
| Write-Host $_.FullName | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment