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
文件。
Default Website
dscResource)状态的文档(添加了强调):
Path到网站位置(IIS或WebAdministration格式)。
this提出,web.config
参数所期望的file -system
路径,而是以IIS术语表达的一个路径,在(我推断的 - 未经我测试)中是两种支持格式之一:
ANIIS内部路径,例如由IIS site-Formformation对象的the cmdlet从
WebConfigProperty
模块返回的IIS site-formention对象的属性。
WebSitePath
路径,基于 - 过时 -