Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-2310

DSC - The "File" Resource Fails when a Unicode Destination Path is Specified

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • None
    • None
    • dsc
    • Module Version: 0.1.1-b20052-33d43b62
      Puppet Agent Version: 1.2.2 (Gold)
      Agent: Windows 2012 R2 x64

    • Modules
    • 1

    Description

      Description

      If a user specifies a Unicode path for a "file" DSC resource the Puppet run will fail:

      Notice: Compiled catalog for w2012r2.vm in environment production in 0.39 seconds
      Error: Execution of 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -Command $script:ErrorActionPreference = 'Stop'
      $PuppetModulesFolder = Join-Path $env:ProgramFiles 'WindowsPowerShell\Modules\PuppetVendoredModules'
      if (!(Test-Path($PuppetModulesFolder))) {
        & cmd.exe /c mklink /d "$PuppetModulesFolder" "C:\ProgramData\PuppetLabs\code\environments\production\modules\dsc\vendor\DSCResources" | Out-Null
      }
       
      $currentState = Get-DscLocalConfigurationManager
       
      if ($currentState.RefreshMode -ne 'Disabled') {
        throw "DSC LCM RefreshMode must be set to Disabled for Puppet to execute DSC Resources!"
      }
       
      $invokeParams = @{
        Name          = 'File'
        Method        = 'set'
        Property      = @{
          destinationpath = 'C:\?????????????'
          ensure = 'Present'
        }
        ModuleName = "PSDesiredStateConfiguration"
      }
       
      $result = Invoke-DscResource @invokeParams
       
      switch ($invokeParams.Method) {
        'Test' {
          [bool]($result.InDesiredState)
        }
        'Set' {
          @($Null, 0) -contains $result.ReturnValue
        }
      }
      ' returned 1: Invoke-CimMethod : Specified arguments not valid. To create an empty file with
      this name, include the Contents property with a value of an empty string. The
      related ResourceID is [File]DirectResourceAccess.
      At line:23 char:1
      + $result = Invoke-DscResource @invokeParams
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (root/Microsoft/...gurationMana
         ger:String) [Invoke-CimMethod], CimException
          + FullyQualifiedErrorId : MI RESULT 4,Microsoft.Management.Infrastructure.
         CimCmdlets.InvokeCimMethodCommand
      Error: /Stage[main]/Main/Dsc_file[file_test]/ensure: change from absent to present failed: Execution of 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -Command $script:ErrorActionPreference = 'Stop'
      $PuppetModulesFolder = Join-Path $env:ProgramFiles 'WindowsPowerShell\Modules\PuppetVendoredModules'
      if (!(Test-Path($PuppetModulesFolder))) {
        & cmd.exe /c mklink /d "$PuppetModulesFolder" "C:\ProgramData\PuppetLabs\code\environments\production\modules\dsc\vendor\DSCResources" | Out-Null
      }
       
      $currentState = Get-DscLocalConfigurationManager
       
      if ($currentState.RefreshMode -ne 'Disabled') {
        throw "DSC LCM RefreshMode must be set to Disabled for Puppet to execute DSC Resources!"
      }
       
      $invokeParams = @{
        Name          = 'File'
        Method        = 'set'
        Property      = @{
          destinationpath = 'C:\?????????????'
          ensure = 'Present'
        }
        ModuleName = "PSDesiredStateConfiguration"
      }
       
      $result = Invoke-DscResource @invokeParams
       
      switch ($invokeParams.Method) {
        'Test' {
          [bool]($result.InDesiredState)
        }
        'Set' {
          @($Null, 0) -contains $result.ReturnValue
        }
      }
      ' returned 1: Invoke-CimMethod : Specified arguments not valid. To create an empty file with
      this name, include the Contents property with a value of an empty string. The
      related ResourceID is [File]DirectResourceAccess.
      At line:23 char:1
      + $result = Invoke-DscResource @invokeParams
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (root/Microsoft/...gurationMana
         ger:String) [Invoke-CimMethod], CimException
          + FullyQualifiedErrorId : MI RESULT 4,Microsoft.Management.Infrastructure.
         CimCmdlets.InvokeCimMethodCommand
      Notice: Applied catalog in 4.15 seconds

      Attachments

      • Test Manifest

      Repro Steps

      1. Install Puppet Agent on Windows node.
      2. Install DSC module from the modules staging Forge:

        puppet module install puppetlabs-dsc --module_repository https://api-module-staging.puppetlabs.com

      3. Download the attached manifest to the Windows agent.
      4. Apply the manifest on Windows node:
      5. puppet apply test_manifest.pp

      Expect

      The Puppet run should succeed.

      Actual

      The Puppet run fails:

      Notice: Compiled catalog for w2012r2.vm in environment production in 0.39 seconds
      Error: Execution of 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -Command $script:ErrorActionPreference = 'Stop'
      $PuppetModulesFolder = Join-Path $env:ProgramFiles 'WindowsPowerShell\Modules\PuppetVendoredModules'
      if (!(Test-Path($PuppetModulesFolder))) {
        & cmd.exe /c mklink /d "$PuppetModulesFolder" "C:\ProgramData\PuppetLabs\code\environments\production\modules\dsc\vendor\DSCResources" | Out-Null
      }
       
      $currentState = Get-DscLocalConfigurationManager
       
      if ($currentState.RefreshMode -ne 'Disabled') {
        throw "DSC LCM RefreshMode must be set to Disabled for Puppet to execute DSC Resources!"
      }
       
      $invokeParams = @{
        Name          = 'File'
        Method        = 'set'
        Property      = @{
          destinationpath = 'C:\?????????????'
          ensure = 'Present'
        }
        ModuleName = "PSDesiredStateConfiguration"
      }
       
      $result = Invoke-DscResource @invokeParams
       
      switch ($invokeParams.Method) {
        'Test' {
          [bool]($result.InDesiredState)
        }
        'Set' {
          @($Null, 0) -contains $result.ReturnValue
        }
      }
      ' returned 1: Invoke-CimMethod : Specified arguments not valid. To create an empty file with
      this name, include the Contents property with a value of an empty string. The
      related ResourceID is [File]DirectResourceAccess.
      At line:23 char:1
      + $result = Invoke-DscResource @invokeParams
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (root/Microsoft/...gurationMana
         ger:String) [Invoke-CimMethod], CimException
          + FullyQualifiedErrorId : MI RESULT 4,Microsoft.Management.Infrastructure.
         CimCmdlets.InvokeCimMethodCommand
      Error: /Stage[main]/Main/Dsc_file[file_test]/ensure: change from absent to present failed: Execution of 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -Command $script:ErrorActionPreference = 'Stop'
      $PuppetModulesFolder = Join-Path $env:ProgramFiles 'WindowsPowerShell\Modules\PuppetVendoredModules'
      if (!(Test-Path($PuppetModulesFolder))) {
        & cmd.exe /c mklink /d "$PuppetModulesFolder" "C:\ProgramData\PuppetLabs\code\environments\production\modules\dsc\vendor\DSCResources" | Out-Null
      }
       
      $currentState = Get-DscLocalConfigurationManager
       
      if ($currentState.RefreshMode -ne 'Disabled') {
        throw "DSC LCM RefreshMode must be set to Disabled for Puppet to execute DSC Resources!"
      }
       
      $invokeParams = @{
        Name          = 'File'
        Method        = 'set'
        Property      = @{
          destinationpath = 'C:\?????????????'
          ensure = 'Present'
        }
        ModuleName = "PSDesiredStateConfiguration"
      }
       
      $result = Invoke-DscResource @invokeParams
       
      switch ($invokeParams.Method) {
        'Test' {
          [bool]($result.InDesiredState)
        }
        'Set' {
          @($Null, 0) -contains $result.ReturnValue
        }
      }
      ' returned 1: Invoke-CimMethod : Specified arguments not valid. To create an empty file with
      this name, include the Contents property with a value of an empty string. The
      related ResourceID is [File]DirectResourceAccess.
      At line:23 char:1
      + $result = Invoke-DscResource @invokeParams
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidArgument: (root/Microsoft/...gurationMana
         ger:String) [Invoke-CimMethod], CimException
          + FullyQualifiedErrorId : MI RESULT 4,Microsoft.Management.Infrastructure.
         CimCmdlets.InvokeCimMethodCommand
      Notice: Applied catalog in 4.15 seconds

      Attachments

        Issue Links

          Activity

            People

              ethan Ethan Brown
              ryan.gard Ryan Gard
              Ryan Gard Ryan Gard
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Zendesk Support