Copy Directory using DSC not syncing

This topic contains 5 replies, has 2 voices, and was last updated by Profile photo of Amit Batham Amit Batham 1 week, 4 days ago.

  • Author
    Posts
  • #58588
    Profile photo of Amit Batham
    Amit Batham
    Participant

    Hello Team,

    I have got below 2 issues

    1) I have created below script for copying my directory using push server. It works fine & copies all sub directories/files when applies DSC config for the 1st time. After that if i go to any client machine & delete any sub directory , it doesn't sync back to MyDir sitting on Push server.

    $Node = Get-Content -Path "E:\servernames.txt"

    Configuration MyDir
    {
    Import-DscResource -ModuleName PSDesiredStateConfiguration

    Node $Node
    {
    LocalConfigurationManager
    {
    ConfigurationMode = "ApplyAndAutoCorrect"
    }

    File CopyMyDIR
    {
    Ensure = "Present"
    Type = "Directory"
    Recurse = $true
    Matchsource = $true
    Sourcepath = "\\servername\MyDir"
    DestinationPath = "E:\MyDir\"
    }
    }
    }

    MyDir

    2) How can I copy the files to cross domain machines. I understand , I need to pass 2 credentials. My Push server is in Domain 1 , so 1st pass Domain 2 credentials to access & copy the mof file to domain 2 client , 2nd, pass Domain 1 credential to access the My Dir sitting on a share in Domain 1 & copy over.

    I tried creating a Pssession to domain 2 client with domain 2 credential & passing that to start dscconfig command & asking for domain1 credential inside configuration but this way I am able to make session to only 1 machine & that worked fine. As you can see above , I am reading the servernames from a file having list of servers from both the domains; so not sure how to tackle this for all the servers.

  • #58645
    Profile photo of Don Jones
    Don Jones
    Keymaster

    So, I'm not sure what a "push server" is, but I think I understand what you're asking. I would start by examining the DSC log after the next LCM consistency check on the node, and see if you're getting any indications of a problem. You may also want to specify a Checksum property in the configuration, such as Checksum="SHA-512".

    In terms of cross-domain, yes, you'd need to either pass credentials, or have a file source that accepted anonymous connections. The File resource accepts a Credential parameter, and you'd use that to specify the credential needed to access the file server. You don't use PSSessions.

  • #58666
    Profile photo of Amit Batham
    Amit Batham
    Participant

    Hello Don,

    Thanks for reply.

    I added the Checksum property still it's not syncing back. So I ran the DSC-config.. it copied all the files .. I went to Node & deleted 2-3 Sub-Dir ... waited for consistency check so it can copy the deleted directories back but it didn't. I see below in DSC log

    Log Name: Microsoft-Windows-DSC/Operational
    Source: Microsoft-Windows-DSC
    Date: 11/24/2016 11:56:27 PM
    Event ID: 4249
    Task Category: None
    Level: Warning
    Keywords:
    User: SYSTEM
    Computer: *****
    Description:
    Job {82954524-B273-11E6-80C6-005056913066} :
    From LCM, message is
    Completed processing test operation. The operation returned False.

    For Cross domain.. Credential parameter is used to access & copy the Dir from Pushing server which in Domain 1. This node is in Domain 2 so I also need to pass credential of Domain 2 when applying DSC config to Node (Sitting in domain2).That's where I am getting issues.

  • #58667
    Profile photo of Don Jones
    Don Jones
    Keymaster

    So, the LCM realizes that it's not correct – the test is returning False. Unfortunately, the File resource is binary, so there's no real way to troubleshoot it further. You've configured it correctly, as near as I can tell.

    I should point out that there's a "Pull Server," but no such thing as a "Pushing server" in DSC. So I'm not sure what you're writing about there.

    The node's configuration needs to use the Credential or PSCredential property in the File resource. The node's LCM will use that credential to access the shared folder where the files are located.

    File CopyMyDIR
    {
    Ensure = "Present"
    Type = "Directory"
    Recurse = $true
    Matchsource = $true
    Sourcepath = "\\servername\MyDir"
    DestinationPath = "E:\MyDir\"
    Credential = SOMETHING_HERE
    }
    

    In terms of providing a credential so that you can push a configuration to the node, you'd do that with Start-DscConfiguration. It has a -Credential parameter for that purpose. This doesn't use PSSessions – it's a CIM connection to the node.

  • #58669
    Profile photo of Amit Batham
    Amit Batham
    Participant

    Ok .. Understood !!

    If I use -credential parameter with Start-DscConfiguration & pass domain2 credentials then Those credentials will be used for all Nodes. But My $node variable reading the servernames from a list (see my script above) which has Nodes from Domain 1 as well as from Domain2.
    So when -credentials will be used for Domain1 Nodes for applying DScConfig if will throw error.

  • #58672
    Profile photo of Amit Batham
    Amit Batham
    Participant

    Another issue which i am seeing is , it's not updating the Configurationmode Setting for LCM on Nodes. As you can see above , in my Config, I am changing target Nodes LCM Configurationmode Setting but after applying DSC when I go to target node & run get-dsclocalConfigurationmanager .. it's showing configurationmode = ApplyAndMonitor which I did set to "ApplyAndAutoCorrrect"

    Rebooted the Target Nodes still same issue.

You must be logged in to reply to this topic.