xPSDesiredStateConfiguration icon indicating copy to clipboard operation
xPSDesiredStateConfiguration copied to clipboard

xRemoteFile -MatchSource just dose not do what it should

Open madmikep opened this issue 7 years ago • 1 comments

I have a Pull server configured with a Virtual Directory that I place zip files in for example a Web site source files name.zip. I have a configuration set to download the file using xRemoteFile and this works fine. The problem is if I updated the zip file on the source (Pull Server Virtual Directory) xRemoteFile will never download the updated zip file even if I set the MatchSource to $true

with MatchSource set to $true it reports "Cache reflects current state. No need for downloading file." which is not correct because the source of the ZIP file has changed with MatchSource set to $false it reports "MatchSource is false. No need for downloading file." which I would say is correct because I am telling it not to match the source

madmikep avatar Mar 15 '17 23:03 madmikep

I also ran into this issue. I spent some time looking into it and it does not work like I think it would.

If the file is downloaded and then changed on the local machine. xRemoteFile will download a new copy of the file and set that as the new file. But when it does the download, it caches the file date and size. When the Test-DscResource runs, it will compare destination file with the cached values that were collected at the last download. If the file exists and matches the cache values, then the resource indicates that it is in the desired state.

It does not check the source file during the Test-DscResource so it will never know if the source file changes.

We can correct this issue by pulling the URI head so that we don't have to download the entire file.

PS:> Invoke-WebRequest -Method Head -Uri $uri | Select -ExpandProperty Headders

Key            Value
---            -----
Content-Length 1427
Last-Modified  Thu, 06 Apr 2017 19:48:16 GMT

Then we can compare these values that are saved in the cache or on the destination file.

KevinMarquette avatar Apr 06 '17 22:04 KevinMarquette