使用Powershell更改IIS站点主目录 [英] Change IIS Site Home Directory w/ Powershell
问题描述
我可以查询AD并找到所有IIS站点及其虚拟目录,现在我需要能够更新这些主目录并保存更改.
I can query the AD and find all the IIS sites and their virtual directories, now I need to be able to update those home directories and save the changes.
获取目录条目后,可以使用 $ site.Path
显示站点路径,但是设置它似乎没有任何效果.它永远不会更改实际的存储路径.
After I fetch the directory entry I can display the site path using $site.Path
, however setting it doesn't seem to have any effect. It never changes the actual stored path.
我尝试了 $ site.Path =< new path>
和 $ site.Put("Path",< new path>)
,但都没有似乎正在影响存储的路径.
I have tried $site.Path = <new path>
and $site.Put( "Path", <new path> )
but neither have these seem to be affecting the stored 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()
推荐答案
好吧,我尝试了一下,而且似乎可行:
Ok, I tried this and it seems to work:
$s.psbase.properties.path[0] = $siteConfig.path
$s.psbase.CommitChanges()
是否有更好的更清洁的方式来处理此问题?
Is there a better cleaner way of handling this?
这篇关于使用Powershell更改IIS站点主目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!