You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Details of the scenario you tried and the problem that is occurring
Try to include a 'Directory' resource like
MSFT_xFileDirectory {
SourcePath = 'C:\Program Files\WindowsPowerShell\Modules\xActiveDirectory'
DestinationPath = "\Program Files\WindowsPowerShell\Modules"
type = 'Directory'
Recurse = $True
Ensure='Present'
}
The subtree copies correctly.
Then run the Test-DscConfiguration or wait for the Monitor action on complete. There's a false result.
The root cause is that LastWriteTime for the directory is the time of last file operation within the directory, meaning it will never match the timestamp of original directory. SHA-* algorithm also not applicable.
Verbose logs showing the problem
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] SourcePath => C:\Program
Files\WindowsPowerShell\Modules\xActiveDirectory
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Type => Directory
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Ensure => True
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Content =>
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] DestinationPath => \Program
Files\WindowsPowerShell\Modules
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Force => False
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Attributes =>
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Recurse => True
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Testing the file with relative VHD
destination \Program Files\WindowsPowerShell\Modules
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Test returned False
VERBOSE: [DESKTOP-1NHIAMI]: LCM: [ End Test ] [[xVhdFile]Inject DC1] False in 1.2560 seconds.
Suggested solution to the issue
Rewrite ItemHasChanged to separately process directories and files.
The DSC configuration that is used to reproduce the issue (as detailed as possible)
@DmitryMashkov-DM thanks for opening this issue. I have confirmed the issue really stems from using Copy-Item since it doesn't copy the metadata associated for the item. The way I'd like to proceed is replace the use of Copy-Item with robocopy.
Absolutely! That would be great to have it there. Then we can reuse it in SqlServerDsc from there.
johlju
changed the title
xVHDFile: Test-TargetResource is always $false for directories
VhdFile: Test-TargetResource is always $false for directories
Jun 12, 2022
Details of the scenario you tried and the problem that is occurring
Try to include a 'Directory' resource like
MSFT_xFileDirectory {
SourcePath = 'C:\Program Files\WindowsPowerShell\Modules\xActiveDirectory'
DestinationPath = "\Program Files\WindowsPowerShell\Modules"
type = 'Directory'
Recurse = $True
Ensure='Present'
}
The subtree copies correctly.
Then run the Test-DscConfiguration or wait for the Monitor action on complete. There's a false result.
The root cause is that LastWriteTime for the directory is the time of last file operation within the directory, meaning it will never match the timestamp of original directory. SHA-* algorithm also not applicable.
Verbose logs showing the problem
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] SourcePath => C:\Program
Files\WindowsPowerShell\Modules\xActiveDirectory
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Type => Directory
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Ensure => True
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Content =>
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] DestinationPath => \Program
Files\WindowsPowerShell\Modules
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Force => False
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Attributes =>
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Recurse => True
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Testing the file with relative VHD
destination \Program Files\WindowsPowerShell\Modules
VERBOSE: [DESKTOP-1NHIAMI]: [[xVhdFile]Inject DC1] Test returned False
VERBOSE: [DESKTOP-1NHIAMI]: LCM: [ End Test ] [[xVhdFile]Inject DC1] False in 1.2560 seconds.
Suggested solution to the issue
Rewrite ItemHasChanged to separately process directories and files.
The DSC configuration that is used to reproduce the issue (as detailed as possible)
The operating system the target node is running
OsName : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture : 64-bit
WindowsVersion : 2004
WindowsBuildLabEx : 19037.1.amd64fre.vb_release.191202-1231
OsLanguage : en-US
OsMuiLanguages : {en-US, ru-RU}
Version and build of PowerShell the target node is running
Name Value
PSVersion 5.1.19037.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19037.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version of the DSC module that was used ('dev' if using current dev branch)
3.17.0.0
The text was updated successfully, but these errors were encountered: