From d11fd61225c1616cb467e5869763d13a32c6502d Mon Sep 17 00:00:00 2001 From: "olivier.miossec" Date: Thu, 10 Oct 2019 16:34:34 +0200 Subject: [PATCH 1/2] Correction to Virtual Directory Bug 331 --- .../MSFT_xWebVirtualDirectory.psm1 | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 b/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 index 98d7cadb1..b02b018a5 100644 --- a/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 +++ b/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1 @@ -49,9 +49,16 @@ function Get-TargetResource Assert-Module + if ($null -eq $WebApplication -OR $WebApplication.Length -eq 0) + { + $virtualDirectoryName = $Name + } + else { + $virtualDirectoryName = "/$($WebApplication)/$($Name)" + } $virtualDirectory = Get-WebVirtualDirectory -Site $Website ` - -Name $Name ` - -Application $WebApplication + -Name $virtualDirectoryName ` + -Application "" $PhysicalPath = '' $Ensure = 'Absent' @@ -111,9 +118,16 @@ function Set-TargetResource if ($Ensure -eq 'Present') { + if ($null -eq $WebApplication -OR $WebApplication.Length -eq 0) + { + $virtualDirectoryName = $Name + } + else { + $virtualDirectoryName = "/$($WebApplication)/$($Name)" + } $virtualDirectory = Get-WebVirtualDirectory -Site $Website ` - -Name $Name ` - -Application $WebApplication + -Name $virtualDirectoryName ` + -Application "" if ($virtualDirectory.count -eq 0) { Write-Verbose -Message ($LocalizedData.VerboseSetTargetCreateVirtualDirectory -f $Name) @@ -186,9 +200,16 @@ function Test-TargetResource Assert-Module + if ($null -eq $WebApplication -OR $WebApplication.Length -eq 0) + { + $virtualDirectoryName = $Name + } + else { + $virtualDirectoryName = "/$($WebApplication)/$($Name)" + } $virtualDirectory = Get-WebVirtualDirectory -Site $Website ` - -Name $Name ` - -Application $WebApplication + -Name $virtualDirectoryName ` + -Application "" if ($virtualDirectory.Count -eq 1 -and $Ensure -eq 'Present') { From 8e8fb029af259c4e6336e4dbb3c8d487312ab495 Mon Sep 17 00:00:00 2001 From: "olivier.miossec" Date: Thu, 10 Oct 2019 17:10:14 +0200 Subject: [PATCH 2/2] Add Change Log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1154d7b77..f0c07f431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Changes to xWebVirtualDirectory + - Update on how Virtual directory are tested to correct the issue ([issue #331](https://github.com/PowerShell/xWebAdministration/issues/331)). - Changes to xWebAdministration - Resolved custom Script Analyzer rules that was added to the test framework. - Moved change log from README.md to a separate CHANGELOG.md ([issue #446](https://github.com/PowerShell/xWebAdministration/issues/446)).