Powershell命令用于设置IIS日志记录设置 [英] Powershell command to set IIS logging settings

查看:557
本文介绍了Powershell命令用于设置IIS日志记录设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个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%\inetpub \logs \LogFiles到我自己的文件夹,该文件夹不在服务器的启动驱动器上。

The one piece of the puzzle I'm missing though is how to change the default Logging directory from %SystemDrive%\inetpub\logs\LogFiles 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:\Sites\MyNewSite -name logging -value @{format='W3C';directory='d:\sites\site\logs';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()

这篇关于Powershell命令用于设置IIS日志记录设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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