簡體   English   中英

通過PowerShell更改IIS 6主目錄權限

[英]Alter IIS 6 Home Directory permissions via PowerShell

通過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 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
}

編輯:復制每個腳本與每個評論的鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM