DSC File Resource

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Stan Hristov Stan Hristov 4 months, 2 weeks ago.

  • Author
    Posts
  • #47269
    Profile photo of Stan Hristov
    Stan Hristov
    Participant

    Hello,

    I need a certain functionality that is currently missing from the built in DSC File Resource. Before I start to make a custom module for it I wanted to check if someone has a better solution to it.
    Here is what I need.

    I have a network share that has a folder with files A and B and I need to make an exact copy of that folder on the server.
    When I add a new file called C, then it needs to be copied on the server the next time a configuration is applied. I configured the MatchSource property to $true and everything is ok. So far so good.
    Now to the problem. I want to be able to remove file B on the file share and it to be removed from the target folder as well so that only A and C are in it.

    Regards,
    Stan

    • This topic was modified 4 months, 2 weeks ago by Profile photo of Stan Hristov Stan Hristov.
  • #47272
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Sounds to me like you should probably be setting up DFS replication, or something similar. The DSC file resource is not efficient at all for this; even if it did what you wanted, it would be copying down the entire contents of the remote share every time you applied a new config.

  • #47283
    Profile photo of Stan Hristov
    Stan Hristov
    Participant

    Hi,

    Thank you for your fast reply.
    I really don't want to use DFS. One of the reasons (not the primary one) is that the source folder on the file share is different (most of the files inside are the same) and I don't want to reconfigure the DFS replication group settings each time and wait for the changes to take effect.
    Why it will be coping all files every time? If I use some checksum and the files are identical wouldn't it skip them?

  • #47285
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    The DSC file resource has to copy the files down before it can calculate their checksum. It does this into a temporary cache folder on your local disk. This cache is wiped out every time you apply a new configuration.

    The only time checksums can help you cut down on network traffic is if a copy of the checksum is pre-calculated and stored on the remote server along with the actual file. Then your client could download just the checksum first (smaller size, generally), and only grab the whole file if it needs to.

  • #47287
    Profile photo of Stan Hristov
    Stan Hristov
    Participant

    I see, I will think of another solution then perhaps not DSC for this part of our environment setup.
    Thank you very much.

    Best regards,
    Stan

You must be logged in to reply to this topic.