Hi Guys,
Of course I´m not specialist on powershell scripts, but I´m trying to create a simple script that read all txt files and delete all lines that has the strings below.
I would like to improve this script, I would to have a file named exceptions.txt and my script delete all lines in all files that has strings inside the file exceptions.txt, this avoid creating a lot of variable ...
tks
$E1 = "Bin\S"
$E2 = "Desktop\Doc's\Arquivos ALEMÇO\Themen neu 1 audio"
$E3 = "AppData\Local\Microsoft\Windows\Temporary Internet Files\Content"
$E4 = "C:\Adriano"
$E5 = "C:\Users\Public\Music\Sample Music"
$E6 = "English"
$E7 = "L¡nguas"
$E8 = "Windows\winsxs\"
$E9 = "aktuell"
$E10 = "Program Files\Seagull"
$E11 = "ESLP"
$E12 = "android-sdk\samples"
$E13 = "Idiomas"
$E14 = "Francˆs"
$E15 = "French"
$E16 = "Weekly Leader Podcast"
$E17 = "Espanol"
$E18 = "Audio Exercise"
$E19 = "C:\Program Files\Windows"
$E20 = "Chan Kim"
$E21 = "Seagull\BarTender"
$E22 = "Dicas_Office_2007"
$E23 = "Aula Ingles"
$start = "C:\Runbooks\temp\"
Get-ChildItem C:\Runbooks\temp\*.* | Foreach{
$Path = $_.FullName
$content = Get-Content $Path | Where-Object {$_ -Notlike "*$E1*" -and $_ -Notlike "*$E2*" -and $_ -Notlike "*$E3*" -and $_ -Notlike "*$E4*" -and $_ -Notlike "*$E5*" -and $_ -Notlike "*$E6*" -and
$_ -Notlike "*$E7*" -and $_ -Notlike "*$E8*" -and $_ -Notlike "*$E9*" -and $_ -Notlike "*$E10*" -and $_ -Notlike "*$E11*" -and $_ -Notlike "*$E12*" -and $_ -Notlike "*$E13*" -and $_ -Notlike"*$E14*" -and $_ -Notlike "*$E15*" -and $_ -Notlike "*$E16*" -and $_ -Notlike "*$E17*" -and $_ -Notlike "*$E18*" -and $_ -Notlike "*$E19*" -and $_ -Notlike "*$E20*" -and $_ -Notlike "*$E21*"
-and $_ -Notlike "*$E22*" -and $_ -Notlike "*$E23*"}
$content | Set-Content $Path -Force
}
Certified (35) | ITIL | MCP | MCDST | MCSA1 | MCSE1 | MCT | MCTS Sharepoint | MCITP SQL | MCSA Windows 2012 | MTA Security | MCSE Windows 8 | MCSE Windows 2012 | Vencedor do Winthe7.com.br 2009, Quarto lugar Copa de Talentos Microsoft 2010