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
Current result with the resource: UserParameter=Get-ChildItem -Recurse CERT:LocalMachine/My | ? { # This is a configuration file for Zabbix agent 2 (Windows)...
I have the impression that as soon as the resource meets the $ sign, it replaces it with the content of the file.
Thank you.
Verbose logs
VERBOSE: [SRV]: LCM: [ Start Test ] [[KeyValuePairFile]ZabbixConf]
VERBOSE: [SRV]: [[KeyValuePairFile]ZabbixConf] Searching for key 'UserParameter' in file 'C:\Temp\zab.conf'.
VERBOSE: [SRV]: LCM: [ End Test ] [[KeyValuePairFile]ZabbixConf] in 0.0490 seconds.
VERBOSE: [SRV]: LCM: [ Start Set ] [[KeyValuePairFile]ZabbixConf]
VERBOSE: [SRV]: [[KeyValuePairFile]ZabbixConf] Searching for key 'UserParameter' in file 'C:\Temp\zab.conf'.
VERBOSE: [SRV]: [[KeyValuePairFile]ZabbixConf] Key 'UserParameter' found in file 'C:\Temp\zab.conf' and has been updated.
VERBOSE: [SRV]: LCM: [ End Set ] [[KeyValuePairFile]ZabbixConf] in 0.0780 seconds.
VERBOSE: [SRV]: LCM: [ End Resource ] [[KeyValuePairFile]ZabbixConf]
Problem description
Hello,
I want to modify a .conf file using the KeyValuePairFile resource.
The key UserParameter in the .conf file should be the following powershell command:
Get-ChildItem -Recurse CERT:LocalMachine/My | ? { $_.NotAfter -lt (Get-Date).AddMonths(2) } | % { $s=$_.Subject -replace "CN=",""; $e=$_.NotAfter.ToString(); $l=$s+"|"+$e; write-output $l }
However, the resource fails to handle the $ sign, and the result is not as desired.
Expected result:
UserParameter=Get-ChildItem -Recurse CERT:LocalMachine/My | ? { $_.NotAfter -lt (Get-Date).AddMonths(2) } | % { $s=$_.Subject -replace "CN=",""; $e=$_.NotAfter.ToString(); $l=$s+"|"+$e; write-output $l }
Current result with the resource:
UserParameter=Get-ChildItem -Recurse CERT:LocalMachine/My | ? { # This is a configuration file for Zabbix agent 2 (Windows)...
I have the impression that as soon as the resource meets the $ sign, it replaces it with the content of the file.
Thank you.
Verbose logs
DSC configuration
Suggested solution
No :(
Operating system the target node is running
PowerShell version and build the target node is running
FileContentDsc version
The text was updated successfully, but these errors were encountered: