用于设置 IIS 日志记录设置的 Powershell 命令 [英] Powershell command to set IIS logging settings
问题描述
我正在创建一个 powershell 脚本,以便我可以使用 IIS Powershell 管理控制台通过单个命令创建网站托管.
I'm creating a powershell script so I can create website hosting with a single command using the IIS Powershell Management Console.
我有创建 IIS 站点和添加域名绑定等所需的命令...
I have the commands I need to create the IIS Site and add bindings for the domain names etc...
我遗漏的一个难题是如何将默认日志目录从 %SystemDrive%inetpublogsLogFiles 更改为不在服务器启动驱动器上的我自己的文件夹.
The one piece of the puzzle I'm missing though is how to change the default Logging directory from %SystemDrive%inetpublogsLogFiles to my own folder that's not on the boot drive of the server.
经过大量搜索后,我希望能找到与以下伪 powershell 类似的命令
After extensive searching I expected to find a command along the lines of the following pseudo powershell
New-ItemProperty IIS:SitesMyNewSite -name logging -value @{format='W3C';directory='d:sitessitelogs';encoding=UTF-8}
请举例说明如何更改 IIS Powershell 管理控制台中的日志记录文件夹
Please could you show me with an example how you change the logging folder in the IIS Powershell Management Console
提前致谢
推荐答案
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$iis = new-object Microsoft.Web.Administration.ServerManager
$web = $iis.Sites["test"]
#set new logpath, must be existing
$web.LogFile.Directory = "F:Logfiles"
$iis.CommitChanges()
这篇关于用于设置 IIS 日志记录设置的 Powershell 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!