Cleaning unwanted data from IIS log files.

Discussion in 'Scripting' started by ThatVaiGuy, Dec 28, 2009.

  1. ThatVaiGuy

    ThatVaiGuy Guest

    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 \
    cd iis1-w3svc1
    (Type \\iisserver\w3svc1\$filename) -notmatch "" -notmatch
    "" | 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.
    ThatVaiGuy, Dec 28, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.