我使用PowerShell脚本来设置一些环境变量 -
$env:FACTER_Variable_Name = $Variable_Value
Run Code Online (Sandbox Code Playgroud)
FACTER用于在puppet脚本中使用它们.
我的问题是 - 变量名和变量值都是动态的,并从文本文件中读取.
我正在尝试使用
$env:FACTER_$Variable_Name = $Variable_Value
Run Code Online (Sandbox Code Playgroud)
但是$是不可接受的语法.当我用双引号括起来时,变量值不会被传递.任何建议如何动态使用它.
提前致谢
我有一个包含以下内容的 json 文件 -
{
"IsEnabled": true,
"EngineConfiguration": {
"PollInterval": "00:00:15",
"Components": [{
"Id": "Logs",
"FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogDirectoryPath": "C:\\log\\2018-05-25",
"TimestampFormat": "yyyy-MM-dd HH:mm:ss",
"Encoding": "UTF-8",
"Filter": "",
"CultureName": "en-US",
"TimeZoneKind": "UTC",
"LineCount": "1"
}
}]
}
}
Run Code Online (Sandbox Code Playgroud)
我想每天使用 Powershell 使用托管任务替换此日期(在 LogDirectoryPath 中提到)。
有人可以提供最简单的方法来每天使用powershell替换它吗?