You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PowerShell创建带特定属性的IIS站点遇配置错误求助

Hey there! Let's work through this IIS site automation headache with PowerShell—totally get it, piecing together snippets when you're new to a language can be frustrating. Since you mentioned the Set-WebConfigurationProperty command is throwing an error, let's break down the most common issues and fix this step by step.

Top reasons this command fails

  • Incomplete/incorrect Filter path: The Filter parameter uses XPath to target specific IIS config nodes, and a truncated path like /s... will definitely break things. You need a full, precise path to the setting you want to change.
  • Missing required parameters: This cmdlet needs specific arguments like -Name (the property you're modifying), -Value (the new value), and -PSPath (to target the IIS configuration store).
  • Permission issues: You must run PowerShell as an administrator—otherwise, you'll hit access denied errors when modifying IIS settings.

Working example to reference

Let's use common repeat tasks (setting physical path or updating bindings) as a tested template:

# Always run PowerShell as Administrator!
# 1. First, create the new IIS site (if you haven't already)
New-WebSite -Name "AutoDeployedSite" -Port 8081 -PhysicalPath "C:\inetpub\AutoDeployedSite" -ApplicationPool "DefaultAppPool"

# 2. Update the site's physical path
Set-WebConfigurationProperty -Filter "/system.applicationHost/sites/site[@name='AutoDeployedSite']/application[@path='/']/virtualDirectory[@path='/']" `
    -Name "physicalPath" `
    -Value "C:\inetpub\UpdatedAutoSitePath" `
    -PSPath "IIS:\"

# 3. Update the site's HTTP binding to use a custom host name
Set-WebConfigurationProperty -Filter "/system.applicationHost/sites/site[@name='AutoDeployedSite']/bindings/binding[@protocol='http' and @bindingInformation='*:8081:']" `
    -Name "bindingInformation" `
    -Value "*:8081:autosite.local" `
    -PSPath "IIS:\"

Key parts explained

  • Filter: The XPath path targets exactly what you want to modify. For example, site[@name='AutoDeployedSite'] ensures you're only affecting that specific site, not all sites.
  • -Name: This is the specific property you're changing—like physicalPath for the site's file location, or bindingInformation for its port/host name.
  • -PSPath: This tells PowerShell to target the IIS configuration store, using IIS:\ as the path.

Next steps for your script

  1. Replace the truncated /s... in your Filter with a full, valid XPath path matching the setting you need to configure (use the examples above as a template).
  2. Double-check that you've included all required parameters: -Filter, -Name, -Value, and -PSPath.
  3. Make sure you're running PowerShell as an administrator—right-click PowerShell and select "Run as administrator".
  4. If you still get an error, copy the exact error message and share it—this will help pinpoint the issue even faster!

内容的提问来源于stack exchange,提问作者Jerry L

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:10:35