Details of the scenario you tried and the problem that is occurring
"Get-TargetResource" and "Invoke-DscResource -> Get" should have the same output. Invoke-DscResource returns a list of data, as expected, but values that should contain objects or array lists are "System.Object[]"
test 1, as it should be, just an example for "Network_access_Sharing_and_security_model_for_local_accounts"
Import-Module "C:\Program Files\WindowsPowerShell\Modules\SecurityPolicyDsc\2.10.0.0\DSCResources\MSFT_SecurityOption\MSFT_SecurityOption.psm1"
Get-TargetResource -Name "Network_access_Sharing_and_security_model_for_local_accounts"
output
...
Network_access_Sharingand... {Classic - Local users authenticate as themselves}
...
test 2, as it is
Invoke-DscResource -ModuleName SecurityPolicyDsc -Name securityoption -Method Get -Property @{ "Name"="Network_access_Sharing_and_security_model_for_local_accounts" }
The problem seems to be in
MSFT_SecurityOption.psm1
[array] $resultValue = ConvertTo-CimRestrictedRemoteSam -InputObject $currentValue
which hard-types $resultValue for all following cycles
--> moving [array] to the declaring side, does the trick
$resultValue = [array](ConvertTo-CimRestrictedRemoteSam -InputObject $currentValue)
The DSC configuration that is used to reproduce the issue (as detailed as possible)
Powershell 5.1, just plain Start / Run as / "powershell.exe"
# insert configuration here
The operating system the target node is running
Windows 10 21h2, Windows 2019 1809, German, English
Details of the scenario you tried and the problem that is occurring
"Get-TargetResource" and "Invoke-DscResource -> Get" should have the same output. Invoke-DscResource returns a list of data, as expected, but values that should contain objects or array lists are "System.Object[]"
test 1, as it should be, just an example for "Network_access_Sharing_and_security_model_for_local_accounts" Import-Module "C:\Program Files\WindowsPowerShell\Modules\SecurityPolicyDsc\2.10.0.0\DSCResources\MSFT_SecurityOption\MSFT_SecurityOption.psm1" Get-TargetResource -Name "Network_access_Sharing_and_security_model_for_local_accounts"
output ... Network_access_Sharingand... {Classic - Local users authenticate as themselves} ...
test 2, as it is Invoke-DscResource -ModuleName SecurityPolicyDsc -Name securityoption -Method Get -Property @{ "Name"="Network_access_Sharing_and_security_model_for_local_accounts" }
output ... Network_access_Sharing_and_security_model_for_local_accounts : System.Object[] ...
Verbose logs showing the problem
Not important
Suggested solution to the issue
The problem seems to be in MSFT_SecurityOption.psm1 [array] $resultValue = ConvertTo-CimRestrictedRemoteSam -InputObject $currentValue which hard-types $resultValue for all following cycles
--> moving [array] to the declaring side, does the trick $resultValue = [array](ConvertTo-CimRestrictedRemoteSam -InputObject $currentValue)
The DSC configuration that is used to reproduce the issue (as detailed as possible)
Powershell 5.1, just plain Start / Run as / "powershell.exe"
The operating system the target node is running
Windows 10 21h2, Windows 2019 1809, German, English
OsName : Microsoft Windows 10 Enterprise OsOperatingSystemSKU : EnterpriseEdition OsArchitecture : 64-Bit WindowsVersion : 2009 WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406 OsLanguage : de-DE OsMuiLanguages : {de-DE}
Version and build of PowerShell the target node is running
Name Value
PSVersion 5.1.19041.1320 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.1320 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Version of the DSC module that was used
v2.10.0.0