Closed dbaileyut closed 4 years ago
Hmm, actually, there's some weirdness because I can run
Get-PolicyOptionData -FilePath 'C:\Program Files\WindowsPowerShell\Modules\SecurityPolicyDsc\DSCResources\MSFT_AccountPolicy\AccountPolicyData.psd1'
from powershell.exe or the ISE.
If I modify Get-PolicyOptionData by removing (or moving) the hashtable type from the -FilePath parameter the configuration applies successfully.
Removing:
function Get-PolicyOptionData
{
[OutputType([hashtable])]
[CmdletBinding()]
Param
(
[Parameter(Mandatory = $true)]
[Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformation()]
#[hashtable] # < removing this works
$FilePath
)
return $FilePath
}
Moving:
function Get-PolicyOptionData
{
[OutputType([hashtable])]
[CmdletBinding()]
Param
(
[Parameter(Mandatory = $true)]
[hashtable] # < moving this here works
[Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformation()]
$FilePath
)
return $FilePath
}
Hi @dbaileyut, the minimum PowerShell version for this module is now 5.1.
Details of the scenario you tried and the problem that is occurring
Trying to use AccountPolicy on Windows 2012R2 with PowerShell 4.0
Verbose logs showing the problem
Suggested solution to the issue
It looks like ArgumentToConfigurationDataTransformation requires PowerShell 5.x?
Maybe load the hashtable in AccountPolicyData.psd1 without it? Less preferred: Increase the minimum PowerShell/DSC version for the module.
https://github.com/PowerShell/SecurityPolicyDsc/blob/bf628170a2d51efb282c3b33a10fb29d7bc5af51/Modules/SecurityPolicyResourceHelper/SecurityPolicyResourceHelper.psm1#L435-L447
The DSC configuration that is used to reproduce the issue (as detailed as possible)
The operating system the target node is running
OSName : Windows Server 2012R2 OSArchitecture : 64-bit WindowsVersion: 6.3 (Build 9600) OsLanguage: en-us
Patched up to May 2019
Version and build of PowerShell the target node is running
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.19170
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
Version of the DSC module that was used ('dev' if using current dev branch)
SecurityPolicyDsc 2.8.0.0