我需要一个脚本来从另一个脚本中提取数据。这是我所拥有的:
$myvar = (cat "C:\ProgramData\CrashPlan\log\app.log" | Select-String -pattern "<path include=")
$v = $myvar -replace '.*='
$vv = $v -replace '/>'
$first = $vv | select-object -first 1
$second = $vv | select-object -skip 1 | select-object -first 1
$third = $vv | select-object -skip 2 | select-object -first 1
$fourth = $vv | select-object -skip 3 | select-object -first 1
$fifth = $vv | select-object -skip 4 | select-object -first 1
cd "C:\pcheck\CheckPermissions"
.\CheckPermissions.ps1 $first
运行上面的命令时,即使我确认$ first的输出是“ E:\”,我仍然得到“找不到目录”的信息。
谢谢!
答案 0 :(得分:0)
选择字符串返回具有许多属性的对象。我想你想要line属性。
$myvar = (cat "C:\ProgramData\CrashPlan\log\app.log" |
Select-String -pattern "<path include=").line