ComputerManagementDsc
ComputerManagementDsc copied to clipboard
SmbShare: Configuration drift due to sort ordering of access properties
Details of the scenario you tried and the problem that is occurring
When using the SmbShare resource the access array properties are not sorted so if the order does not match the operating system (which doesn't appear to sort alphabetically), the configuration constantly drifts.
Verbose logs showing the problem
VERBOSE: [SKYPE19-DB-FD1]: LCM: [ Start Resource ] [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db]
VERBOSE: [SKYPE19-DB-FD1]: LCM: [ Start Test ] [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db]
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] Determining if the SMB share 'db-stage' is in the desired state.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] Getting the current state of the SMB share 'db-stage'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] The SMB share with the name 'db-stage' exist. Evaluating the properties of the SMB share.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] Comparing values in property 'FullAccess'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] NOTMATCH: Value [0] (type 'String') for property 'FullAccess' does match. Current state is 'NT SERVICE\MSSQLSERVER' and desired state is '#DOMAIN#\SKYPE19-DB-FD1$'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] NOTMATCH: Value [1] (type 'String') for property 'FullAccess' does match. Current state is '#DOMAIN#\SKYPE19-DB-FD1$' and desired state is '#DOMAIN#\SKYPE19-DB-FD2$'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] NOTMATCH: Value [2] (type 'String') for property 'FullAccess' does match. Current state is '#DOMAIN#\SKYPE19-DB-FD2$' and desired state is 'NT SERVICE\MSSQLSERVER'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'String') for property 'Ensure' does match. Current state is 'Present' and desired state is 'Present'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'Boolean') for property 'ContinuouslyAvailable' does match. Current state is 'False' and desired state is 'False'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'String') for property 'FolderEnumerationMode' does match. Current state is 'AccessBased' and desired state is 'AccessBased'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'String') for property 'Name' does match. Current state is 'db-stage' and desired state is 'db-stage'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'String') for property 'CachingMode' does match. Current state is 'None' and desired state is 'None'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'String') for property 'Path' does match. Current state is 'C:\db-stage' and desired state is 'C:\db-stage'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] MATCH: Value (type 'Boolean') for property 'EncryptData' does match. Current state is 'False' and desired state is 'False'.
VERBOSE: [SKYPE19-DB-FD1]: [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] Test-DscParameter result is 'False'.
VERBOSE: [SKYPE19-DB-FD1]: LCM: [ End Test ] [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db] False in 0.9670 seconds.
VERBOSE: [SKYPE19-DB-FD1]: LCM: [ End Resource ] [[SmbShare]CreateDbStageShare::[profile_skype19_db]profile_skype19_db]
Suggested solution to the issue
Sort both the arrays both from the configuration and in the Get-TargetResource function before performing the compare.
The DSC configuration that is used to reproduce the issue (as detailed as possible)
SmbShare CreateDbStageShare
{
Name = 'db-stage'
Path = 'C:\db-stage'
Ensure = 'Present'
EncryptData = $false
FolderEnumerationMode = 'AccessBased'
CachingMode = 'None'
ContinuouslyAvailable = $false
FullAccess = @('#DOMAIN#\SKYPE19-DB-FD1$','#DOMAIN#\SKYPE19-DB-FD2$','NT SERVICE\MSSQLSERVER')
}
The operating system the target node is running
OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
Name Value
---- -----
PSVersion 5.1.17763.316
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.316
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)
ComputerManagementDsc , Version: 6.5.0.0
Great catch @dappleby300 - hopefully is an easy fix. Will get onto it as soon as possible.
I'll be able to implement the fix in this one once #252 is merged.
#252 has been merged so I can get onto this one.
@PlagueHO Sorry to bug you again but wondering whether it'd be possible for you to fix this? Alternatively happy to have a go myself - I'm guessing the new -SortArrayValues parameter should be passed to Test-DscParameterState - anything else you're aware of?
Hi @Borgquite , I'm happy if you want to have a go at fixing! I'm a bit tied up with Global Azure event today :/
Thanks to @Borgquite for fixing this. Please test and verify that it works by using the preview that will be released shortly.