[英]Change IIS Site Home Directory w/ Powershell
我可以查詢AD並找到所有IIS站點及其虛擬目錄,現在我需要能夠更新這些主目錄並保存更改。
在我獲取目錄條目后,我可以使用$site.Path
顯示站點路徑,但是設置它似乎沒有任何效果。 它永遠不會改變實際存儲的路徑。
我嘗試過$site.Path = <new path>
和$site.Put( "Path", <new path> )
但這些似乎都沒有影響存儲的路徑。
$site = $iis.psbase.children |
where {$_.keyType -eq "iiswebserver"} |
where {$_.psbase.properties.servercomment -eq $siteConfig.name };
$s = [ADSI]($site.psbase.path + "/ROOT");
$s.Path
# $s.Path = $siteConfig.path
# $s.Put("Path", $siteConfig.path )
$s.psbase.CommitChanges()
Import-Module WebAdministration
Set-ItemProperty 'IIS:\Sites\Default Web Site\' -name physicalPath -value $siteConfig.path
http://technet.microsoft.com/en-us/library/ee909471(WS.10).aspx
好的,我試過這個似乎工作:
$s.psbase.properties.path[0] = $siteConfig.path
$s.psbase.CommitChanges()
有更好的清潔方式來處理這個問題嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.