Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 如何获取此写入输出的3行_Powershell_Powershell 4.0 - Fatal编程技术网

Powershell 如何获取此写入输出的3行

Powershell 如何获取此写入输出的3行,powershell,powershell-4.0,Powershell,Powershell 4.0,我不知道如何获取此输出的第三行。有人能帮我做备份专栏的第三行吗?我想用这个日期和时间制作一些东西,这是输出: 这是我的代码: cd "C:\Program Files\Veritas\NetBackup\bin" $output = .\bpclimagelist.exe -ct 0 Write-Output $output | Format-list -Property Expires 我什么都试过了,但不知道该怎么做。如果$output是字符串数组: $output[2].Subst

我不知道如何获取此输出的第三行。有人能帮我做备份专栏的第三行吗?我想用这个日期和时间制作一些东西,这是输出:

这是我的代码:

cd "C:\Program Files\Veritas\NetBackup\bin"

$output = .\bpclimagelist.exe -ct 0

Write-Output $output | Format-list -Property Expires

我什么都试过了,但不知道该怎么做。

如果$output是字符串数组:

$output[2].Substring(0,16)
如果$output是多行字符串:

($output -Split "`n")[2].Substring(0,16)
您将从第三行获得日期

如果要列出所有日期,请使用

$output[2..$($output.Count - 1)]|Foreach{$_.Substring(0,16)}

查看图像,属性
Expires
似乎是一个对象数组。在这种情况下,
$output.Expires[2]。“备份的”
应该为您提供此列的第三个值。如果不是这样,请执行
$output.Expires.GetType().FullName
以显示它的真实情况。实际上
$output
是一个对象或字符串(
$output | Get Member
)?因为您从bpclimagelist.exe收到它,通常您会得到文本/字符串,而不是对象。如果我想获取策略列?,我只想获取该列1行中的一些字符,谢谢。