uwaadmin
asked on
Script to check log file location of each site in IIS7
I have a simple script that will go in and purge log files older than x on IIS7 servers but it assumes that the default log location is used inetpub\Logs\LogFiles. I need a script that will check the log file location setting for each site so I don't have to go and manually do it myself.
ASKER
I am no scripter so bear with me. From what I can tell this would require me to enter each websites name manually each time I ran it? I don't know all the website names so I would have to log into each server and find out the name of the site to be able to populate it into the script and if I had to do that I could just check log file location while gathering website names.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, let me give this a whirl.
ASKER
Worked! Thanks!
Import-Module WebAdministration
$yourwebsitename="YourWebs
$website = Get-Item IIS:\Sites\$yourwebsitenam
$LogFileDirectory = $website.logfile.directory
if ($LogFileDirectory -match "(%.*%)\\") {
$LogFileDirectory = $LogFileDirectory -replace "%(.*%)\\","$(cmd /C echo $matches[0])"
}