通过Powershell获取IIS日志位置? [英] Get IIS log location via powershell?

查看:124
本文介绍了通过Powershell获取IIS日志位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本,希望能够在IIS服务器之间轻松移动以分析日志,但是这些服务器将日志存储在不同的位置.有些在C:/上在D:/在W3SVC1中,有些在W3SVC3中.我希望能够使Powershell自行查找此信息,而不必在每个服务器上手动进行编辑. (是的,我是一个懒惰的系统管理员.#automateallthethings.)

I'm writing a script that I'd like to be able to easily move between IIS servers to analyze logs, but these servers store the logs in different places. Some on C:/ some on D:/ some in W3SVC1, some in W3SVC3. I'd like to be able to have powershell look this information up itself rather than having to manually edit this on each server. (Yeah, I'm a lazy sysadmin. #automateallthethings.)

PowerShell是否可以提供此信息?

Is this information available to PowerShell if I maybe pass the domain to it or something?

推荐答案

我发现这很适合我,因为我想知道所有站点的日志目录.

I found this to work for me since I want to know all of the sites log directory.

Import-Module WebAdministration

foreach($WebSite in $(get-website))
    {
    $logFile="$($Website.logFile.directory)\w3svc$($website.id)".replace("%SystemDrive%",$env:SystemDrive)
    Write-host "$($WebSite.name) [$logfile]"
    } 

这篇关于通过Powershell获取IIS日志位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆