我在 .txt 或 .config 中使用 powershell 创建了一个日志文件。它看起来像:
# Hello
## This is readme.txt file
## This is commented line
# This is powershell command output
#
# File generated for read, re-load and edit the values
## -- many more comment is there
# Users can change values..
## There is no relation between $RegPath and $RegValue, this are only variables.
# this are registry path,
$RegPath = (
"\\hklm\software\microsoft\123",
"\\hklm\software\Adobe\123",
"\\hklm\software\Fax\123",
"\\hklm\software\IE\123");
# this are registry value.
$RegValue = (
"0",
"123",
"abc",
"456asdccxv",
"update",
"serv");
#this are some services with 0/1
# Win 7 OS exist
$IsWin7OS = 1
# Service pack installed
$IsSPInstalled = 0
# Check office
$MSOffice = 1
# This setting name is
$SettingName = "ReadMe.txt"
这是示例 ReadMe.txt。我想在 powershell 中读取此文件,并希望在 powershell 平台中获取 $RegPath、$RegValue、$IsWin7OS、$IsSPInstalled、$MSOffice 和 $SettingName 的值。然后我将更新这个值并再次保存在同一个文件中。