通过PowerShell更改IIS 6主目录权限

通过PowerShell更改IIS 6主目录权限,iis,powershell,iis-6,Iis,Powershell,Iis 6,有人知道如何通过powershell更改标记的属性吗? 只有类和属性就足够了:) 谢谢大家! 注意:我没有写这个博客,但它似乎回答了这个问题: <# This function will set the home directory of an IIS 6 website using Powershell 2 (it will not work with v1). You need to pass it the site description (from the Web Site tab

有人知道如何通过powershell更改标记的属性吗? 只有类和属性就足够了:)


谢谢大家!

注意:我没有写这个博客,但它似乎回答了这个问题:

<# This function will set the home directory of an IIS 6 website using Powershell 2 (it will not work with v1).
You need to pass it the site description (from the Web Site tab in IIS), the new path and the server your website is running on (this can be a machine name or an IP address).
You wouldn’t believe how long it took me to get this working. 
Found on: http://eliasbland.wordpress.com/2010/08/03/change-the-home-directory-of-an-iis-6-website-using-powershell-2-and-wmi/

Usage: SetHomeDirectory "mysite.co.uk" "d:\websites\mysite" "myServer"
#>

Function SetHomeDirectory($SiteDescription, $NewPath, $serverName) {
    $query = "ServerComment = '" + $SiteDescription + "'"
    $webserver = Get-WMIObject -class IIsWebServerSetting -namespace "root\microsoftiisv2" -Filter $query -computer $serverName -authentication 6
    $nameQuery = "Name = '" + $webserver.Name + "/root'"
    $webdir = Get-WMIObject -class IIsWebVirtualDirSetting -namespace "root\microsoftiisv2" -Filter $nameQuery -computer $serverName -authentication 6
    $webdir.Path = $NewPath
    Set-WmiInstance -InputObject $webdir
}

函数SetHomeDirectory($SiteDescription、$NewPath、$serverName){
$query=“ServerComment=”+$sitescription+“”
$webserver=Get-WMIOObject-class IIsWebServerSetting-namespace“root\microsoftiisv2”-过滤器$query-计算机$serverName-身份验证6
$nameQuery=“Name=”+$webserver.Name+“/root”
$webdir=Get-WMIObject-class IISWebVirtualSettings-namespace“root\MicrosoftIsv2”-过滤器$nameQuery-计算机$serverName-身份验证6
$webdir.Path=$NewPath
设置WmiInstance-InputObject$webdir
}
编辑:根据注释复制了带有链接的整个脚本