So here's what I have and could use some help. I'm a scripting newbie.
I'm cleaning IPs out of IIS logs in powershell. I'm calculating the current
date and appending it into the file name, changing the directory, and then
running my little type command and piping the results to another file. I can
do this using the type command in powershell like this:
$date = Get-Date -format yyMMdd
$filename = "u_ex$date.log"
cd \
d:
cd iis1-w3svc1
(Type \\iisserver\w3svc1\$filename) -notmatch "10.10.10.2" -notmatch
"10.10.10.3" | out-file $filename
this is working okay for the current day's log file, but now I need to run
this type command on all older log files in the directory to remove the data
I don't want to report on:
Get-ChildItem \\iisserver\w3svc1 -name and run this command on every object
in the folder one at a time, remove the data I don't want with the -notwith
parameter and pipe the results to another file on another machine.
So my question is how can I work with the Get-Childitems file names for the
type command to work and the outfile to work correctly? I know what I want to
do, but I'm having syntax trouble. Am I doing this efficiently?
Someone please help, thanks.
|