DSC File Copy

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
}

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

[quote quote=190342]make sure S:\sss\ss is available in the node where you are pushing this configuration.

[/quote]

 

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

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