Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecurityPolicyDsc: Invoke-DscResource "Get" output is "System.Object[]" #174

Open
hoppi1804 opened this issue Dec 6, 2021 · 0 comments
Open

Comments

@hoppi1804
Copy link

hoppi1804 commented Dec 6, 2021

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_Sharing_and_... {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"

# insert configuration here

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

hoppi1804 added a commit to hoppi1804/SecurityPolicyDsc that referenced this issue Dec 7, 2021
Fixes SecurityPolicyDsc: Invoke-DscResource "Get" output is "System.Object[]"
dsccommunity#174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant