Skip to content

Commit 5648aea

Browse files
authored
Merge pull request #649 from mhendric/FixPublishModulesAndMofsToPullServer
PublishModulesAndMofsToPullServer: Fixes file read bug in Publish-MOFToPullServer
2 parents 33217a0 + e1576fe commit 5648aea

3 files changed

Lines changed: 18 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
- PublishModulesAndMofsToPullServer.psm1:
6+
- Fixes issue in Publish-MOFToPullServer that incorrectly tries to create a
7+
new MOF file instead of reading the existing one.
8+
[issue #575](https://github.com/PowerShell/xPSDesiredStateConfiguration/issues/575)
59
- Fix minor style issues with missing spaces between `param` statements and '('.
610
- MSFT_xDSCWebService:
711
- Removal of commented out code.

DSCPullServerSetup/PublishModulesAndMofsToPullServer.psm1

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ function Publish-MOFToPullServer
421421
[Parameter(Mandatory = $true,
422422
ValueFromPipelineByPropertyName = $true,
423423
Position = 0)]
424+
[ValidateScript({Test-Path -Path $_ -PathType Leaf})]
424425
[System.String]
425426
$FullName,
426427

@@ -438,35 +439,22 @@ function Publish-MOFToPullServer
438439
{
439440
if (-not($OutputFolderPath) -or -not (Test-Path -Path $OutputFolderPath))
440441
{
441-
if (-not(Test-Path $PullServerWebConfig))
442-
{
443-
throw "Web.Config of the pullserver does not exist on the default path $PullServerWebConfig. Please provide the location of your pullserver web configuration using the parameter -PullServerWebConfig or an alternate path where you want to publish the pullserver MOFs to. This Path should exist."
444-
}
445-
else
446-
{
447-
<#
448-
Web.Config of Pull Server found so figure out the module path of the pullserver.
449-
Use this value as output folder path.
450-
#>
451-
$webConfigXml = [System.Xml.XmlDocument] (Get-Content -Path $PullServerWebConfig)
452-
$configXElement = $webConfigXml.SelectNodes("//appSettings/add[@key = 'ConfigurationPath']")
453-
$OutputFolderPath = $configXElement.Value
454-
}
442+
<#
443+
Web.Config of Pull Server found so figure out the module path of the pullserver.
444+
Use this value as output folder path.
445+
#>
446+
$webConfigXml = [System.Xml.XmlDocument] (Get-Content -Path $PullServerWebConfig)
447+
$configXElement = $webConfigXml.SelectNodes("//appSettings/add[@key = 'ConfigurationPath']")
448+
$OutputFolderPath = $configXElement.Value
455449
}
456450
}
457451
Process
458452
{
459-
$fileInfo = New-Item -Path $FullName -ItemType File
460-
if ($fileInfo.Extension -eq '.mof')
453+
$fileItem = Get-Item -Path $FullName
454+
455+
if ($fileItem.Extension -eq '.mof')
461456
{
462-
if (Test-Path -Path $FullName)
463-
{
464-
Copy-Item -Path $FullName -Destination $OutputFolderPath -Force
465-
}
466-
else
467-
{
468-
throw "File not found at $FullName"
469-
}
457+
Copy-Item -Path $FullName -Destination $OutputFolderPath -Force
470458
}
471459
else
472460
{

DSCResources/MSFT_xMsiPackage/MSFT_xMsiPackage.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ function Set-TargetResource
339339
-Namespace 'root\microsoft\windows\servermanager' `
340340
-Class 'MSFT_ServerManagerTasks' `
341341
-Arguments @{
342-
BatchSize = 256
343-
} `
342+
BatchSize = 256
343+
} `
344344
-ErrorAction 'Ignore'
345345

346346
$registryData = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name 'PendingFileRenameOperations' -ErrorAction 'Ignore'

0 commit comments

Comments
 (0)