DSC File Copy

Viewing 3 reply threads
  • Author
    Posts
    • #190324
      Participant
      Topics: 1
      Replies: 1
      Points: 18
      Rank: Member

      Hi,

      I'm trying to copy file from one VM node to another and i get the following error:

      "SourcePath must be accessible for current configuration"

      i tried running the script from my local computer and it was successful

      $inventoryFile = Get-Content -Path "$PSScriptRoot\NodeList.json" -Raw | ConvertFrom-Json
      
      Configuration ServerDeploy {
      param (
      [PSCredential]$Pass
      
      )
      
      Import-DscResource -ModuleName PSDesiredStateConfiguration
      Node $AllNodes.NodeName {
      
      File "Copy Archive"
      {
      SourcePath = "S:\sss\ss" – intentionally removed servers names, but the structure is the same 
      DestinationPath = "\\sss\d$\s" – intentionally removed servers names, but the structure is the same 
      Ensure = "Present"
      Type = "File"
      Credential = $Cred
      Force = $true
      MatchSource = $true
      Recurse = $true
      }
      Archive "Expand Archive"
      {
      Destination = "D:\sss\s"- intentionally removed servers names, but the structure is the same 
      Path = "\\sss\d$\ss\s"- intentionally removed servers names, but the structure is the same 
      Ensure = "Present"
      Credential = $Cred
      Force = $true
      }
      }
      }
      function Deploy-Config () {
      param (
      [PSCredential]$Cred
      
      )
      $ConfigData = @{
      AllNodes = @(
      
      )
      }
      foreach ($server in $inventoryFile.NodeNames) {
      $ConfigData.AllNodes += @{NodeName = $server;PSDscAllowDomainUser = $true;PSDscAllowPlainTextPassword=$true}
      }
      ServerDeploy -ConfigurationData $ConfigData -Cred $Cred -OutputPath "S:\MOF\"
      $cim = New-CimSession -ComputerName $ConfigData.AllNodes.NodeName -Credential $Cred
      Start-DscConfiguration -CimSession $cim -Path "S:\MOF\" -ThrottleLimit 3 -Verbose -Force -Wait
      }
      
    • #190342
      Senior Moderator
      Topics: 8
      Replies: 1140
      Points: 3,922
      Helping Hand
      Rank: Community Hero

      make sure S:\sss\ss is available in the node where you are pushing this configuration.

    • #190486
      Participant
      Topics: 1
      Replies: 1
      Points: 18
      Rank: Member

      make sure S:\sss\ss is available in the node where you are pushing this configuration.

       

      it is available from the node i'm trying to copy, there is an access between the two nodes but yet i'm getting this error

    • #191923
      Participant
      Topics: 1
      Replies: 4
      Points: 39
      Rank: Member

      DSC uses the System account to access this files. The way I see it, you have two options:

      1. Share that folder and assign to Everyone read permissions
      2. Use the PsDscRunAsCredential property of the File resource https://docs.microsoft.com/en-us/powershell/scripting/dsc/reference/resources/windows/fileresource?view=powershell-6
Viewing 3 reply threads
  • You must be logged in to reply to this topic.