如何使用所需状态配置(DSC)为IIS配置URL重写?

问题描述 投票:0回答:1
当自动设置IIS网站时,我会遇到一个问题,需要我使用

URL重写。 但是,我似乎没有正确地使用DSC Resource命令WebConfigProperty

正确。
我尝试使用

Configuration ConfigureRewriteRules { Import-DscResource -ModuleName WebAdministrationDsc -ModuleVersion 4.1.0 Import-DscResource -ModuleName PSDesiredStateConfiguration node localhost { File 'Create_RewriteRulesFile' { Ensure = 'Present' Type = 'File' DestinationPath = 'c:\inetpub\wwwroot\rewriterules.config' Contents = '<!-- some rules -->' Force = $true MatchSource = $true } WebConfigProperty 'Create_RewriteSection' { Ensure = 'Present' WebSitePath = 'c:\inetpub\wwwroot' Filter = 'system.WebServer/rewrite/rules' PropertyName = 'rules' Value = 'configSource = "rewriterules.config"' DependsOn = '[File]Create_RewriteRulesFile' } } } ConfigureRewriteRules Start-DscConfiguration -Path .\ConfigureRewriteRules -Wait -Verbose -Force

[WebConfigProperty]Create_RewriteSection
将生成错误

Path doesn't belong to 'WebAdministration' provider.

显然,我有参数错误。 根据
DDSCCOMMUNITY/WEBADMINISTRATIONDSC
,资源命令应支持IIS和WebAdMinistration格式。

注:我已经指定了此示例中的易用性,但是我已经验证了指定的路径确实包含

WebSitePath
文件。
Edit:将错误消息更改为控制台上的外观。

您链接到(

Default Website
dscResource
)状态的文档(添加了强调):

Path到网站位置(IIS或WebAdministration格式)。

this提出,
powershell sharepoint url-rewriting dsc
1个回答
0
投票
web.config

参数所期望的file -system

路径,而是以
IIS术语表达的一个路径

,在(我推断的 - 未经我测试)中是两种支持格式之一:

ANIIS内部路径,例如由IIS site-Formformation对象的the cmdlet从

WebConfigProperty模块返回的IIS site-formention对象的属性。

andWebSitePath路径,基于 - 过时 - 

    .Path
  • 模块发布的powershell驱动器。

    
        
    	
    
    
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.