diff --git a/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 b/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 index 8a449e915..cb0522887 100644 --- a/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 +++ b/DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1 @@ -153,8 +153,10 @@ function Set-TargetResource $webApplication.physicalPath -ne $PhysicalPath)) { Write-Verbose -Message ($LocalizedData.VerboseSetTargetPhysicalPath -f $Name) + #Note: read this before touching the next line of code: + # https://github.com/PowerShell/xWebAdministration/issues/222 Set-WebConfigurationProperty ` - -Filter $webApplication.ItemXPath ` + -Filter "$($webApplication.ItemXPath)/virtualDirectory[@path='/']" ` -Name physicalPath ` -Value $PhysicalPath } @@ -164,6 +166,8 @@ function Set-TargetResource ($webApplication.applicationPool -ne $WebAppPool)) { Write-Verbose -Message ($LocalizedData.VerboseSetTargetWebAppPool -f $Name) + #Note: read this before touching the next line of code: + # https://github.com/PowerShell/xWebAdministration/issues/222 Set-WebConfigurationProperty ` -Filter $webApplication.ItemXPath ` -Name applicationPool ` diff --git a/Tests/Unit/MSFT_xWebApplication.Tests.ps1 b/Tests/Unit/MSFT_xWebApplication.Tests.ps1 index fae1292ab..94cd0269b 100644 --- a/Tests/Unit/MSFT_xWebApplication.Tests.ps1 +++ b/Tests/Unit/MSFT_xWebApplication.Tests.ps1 @@ -675,7 +675,7 @@ try Assert-MockCalled -CommandName Get-WebApplication -Exactly 1 Assert-MockCalled -CommandName Set-WebConfigurationProperty -Exactly 1 ` -ParameterFilter { ` - ($Filter -eq "/system.applicationHost/sites/site[@name='MockSite']/application[@path='/MockPool']") -And ` + ($Filter -eq "/system.applicationHost/sites/site[@name='MockSite']/application[@path='/MockPool']/virtualDirectory[@path='/']") -And ` ($Name -eq 'physicalPath') -And ` ($Value -eq 'C:\MockSite\MockApp') ` }