我有一个包含以下内容的文本文件:
SEGMENTS="worker01 worker02 worker03 worker04"
WORKER_SEGMENTS="worker01 worker02 worker03 worker04"
#SEGMENTS="worker01"
#WORKER_SEGMENTS="worker01"
我从另一个 powershell 脚本中读取了这个文件,我想创建一个WORKER_SEGMENTS
值数组。我到目前为止:
$workers = Get-Content $strPath"\worker\conf\segments.conf" | Where-Object {$_ -like "*WORKER_SEGMENTS*"}
Write-Host $workers
这产生:
PS Q:\mles\etl-i_test\rc> .\etl.ps1
WORKER_SEGMENTS="worker01 worker02 worker03 worker04" #WORKER_SEGMENTS="worker01"
我只需要worker01
, worker02
, worker03
, worker04
from WORKER_SEGMENTS
(没有前导 #)作为数组。我如何实现这一目标?