简体   繁体   English

如何使用 Powershell 在 IIS 10 上更新站点的“物理路径”?

[英]How to update "physical path" of a site on IIS 10 using Powershell?

When creating a site I manage to set the path with the following line of code创建站点时,我设法使用以下代码行设置路径

New-WebSite -Name "mysite" -port 8084 -PhysicalPath "c:\inetpub\wwwroot" -ApplicationPool "myappPool"

I have tried to figure out how to update the path, nothing found via Configuration Editor.我试图弄清楚如何更新路径,但通过配置编辑器找不到任何东西。 I thought I had it with the following command我以为我用下面的命令

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.applicationHost/sites/site[@name='mysite']/virtualDirectoryDefaults" -name "physicalPath" -value "c:\inetpub\wwwroot\mysite"

...but, it is not virtualdirectory I want to update, but the actual site... ...但是,我要更新的不是虚拟目录,而是实际站点...

You could use below PowerShell command to change the iis site physical path.您可以使用下面的 PowerShell 命令来更改 iis 站点的物理路径。

run PowerShell as administrator.以管理员身份运行 PowerShell。

run below command:运行以下命令:

PS C:\WINDOWS\system32> Import-Module WebAdministration
PS C:\WINDOWS\system32>  Set-ItemProperty IIS:\Sites\sitea -name physicalPath -value "D:\s1"

after changing the path open iis manager and refresh the site.更改路径后打开 iis 管理器并刷新站点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用PowerShell更新现有的IIS 6网站 - How to update existing IIS 6 Web Site using PowerShell 如何在 Teamcity 中使用 Nant 或 PowerShell 部署之前备份 IIS 网站文件夹物理路径 - How to Backup IIS website folder physical Path before deploying using using Nant or PowerShell in Teamcity 如何使用 Power Shell 脚本获取 IIS 站点物理路径和绑定详细信息 - How to get the IIS site Physical path and the Binding details using power shell script 使用Powershell选择IIS物理路径后,如何删除/创建/重命名文件? - How do you delete/create/rename files after selecting the IIS Physical Path using Powershell? 如何通过Powershell设置IIS网站的物理路径凭据? - How to set an IIS Website's Physical Path credentials through Powershell? 这是使用Powershell获取远程IIS服务器上每个站点的物理路径的正确方法吗? - Is this a correct way use powershell to get physical path of each site on a remote IIS server? 防止以纯文本形式获取 IIS 物理路径凭据(使用 powershell) - Protect from getting IIS physical path credentials in plain text (using powershell) 使用Powershell删除并创建IIS 6站点 - Remove and create IIS 6 site using Powershell Powershell,使用 msdeploy 启动或停止 iis 站点 - Powershell, start or stop iis site using msdeploy 使用 powershell 在 IIS 10 中重新绑定证书 - Certificate Rebind in IIS 10 using powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM