$select.Length
没有给出输出。请看以下代码:长度功能没有给出输出
clear
$filePath = "c:\temp\result.txt"
$select = Select-String -Pattern "Final result:" -Path 'C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\Summary.txt' #| Out-File c:\pattern.txt
$select1 = Select-String -Pattern "Final result:" -Path 'C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\Summary.txt' | Out-File D:\temp\pattern.txt
Write-Host($select.Length)
if ($select.Length -gt 0) {
Write-Host 'Contains String'
$select2 = Select-String -Pattern "Passed" -Path 'D:\temp\pattern.txt'
if ($select2.Length -gt 0) {
#Out-File C:\temp\result.txt $filePath -Append
New-Item $filePath -ItemType file
'Success' | Out-File -FilePath $filePath -Append
} else {
New-Item $filePath -ItemType file
'Failed' | Out-File -FilePath $filePath -Append
}
} else {
Write-Host 'Does not contain String'
}
理想的情况下,应该产生与成功作为的Result.txt文本文件,但它不工作。我没有收到任何错误。
你要管的东西了文件。目前out-file将不会写任何 – guiwhatsthat
这是好的至少它应该进入内部没有得到任何东西写入主机($ select.length) – deepti
你怎么知道长度?它匹配多少次? – guiwhatsthat