I'm creating a script to do the following:
Go into the default log file location for Exchange 2003
Get the list of files held inside
If it's E00*.log, I care about it.
If it's res1.log or res2.log or E00tmp.log, then I don't want it.
It grabs the oldest out of the pile of the E00's and grabs the current date.
If the current file is dated before today, then send me an email saying "Your Log files are old".
If it's not, send me an email saying "Your log files are currently within the nominal time frame".
Also it does a count of the entire directory.
So now that you've gotten the background, all I need help with is the code where it's supposed to get that actual one file into usable format.
I can do something like the code listed below
But the problem is it keeps giving me horrible output. I can get it to sort and format-table no problem. I just feel like I'm missing the big picture here. It should be "If it's not this or this, grab the date, stuff it into the variable"
That's all I need. Anyone think they can help me out?
Also, may I sa
$directory = C:\Scripts\*.log
$oldestfile = dir $directory | sort -property lastwritetime | select -first 3