我試圖讓一個腳本,執行以下操作:爲什麼慣於此PowerShell腳本執行
- 打印出文件
- 刪除任何空行
- 過濾掉不包含所有行單詞「重新分配」
- 從每行開頭刪除任何空格和「>」的
一切工作正常,直到我在加函數第4步,之後powershell吐出一堆錯誤。我在這裏做錯了什麼?
PS C:\Users\pzsr7z.000\Desktop\incidentoutput> cat .\csvtest.txt | ? {$_.trim() -ne "" } | sls "^Reassignment$" -Context 1,2 | foreach{ $_.TrimStart(">"," ")}
Method invocation failed because [Microsoft.PowerShell.Commands.MatchInfo] does not contain a method named 'TrimStart'.
At line:1 char:90
+ ... 1,2 | foreach{ $_.TrimStart(">"," ")}
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [Microsoft.PowerShell.Commands.MatchInfo] does not contain a method named 'TrimStart'.
At line:1 char:90
+ ... 1,2 | foreach{ $_.TrimStart(">"," ")}
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [Microsoft.PowerShell.Commands.MatchInfo] does not contain a method named 'TrimStart'.
At line:1 char:90
+ ... 1,2 | foreach{ $_.TrimStart(">"," ")}
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [Microsoft.PowerShell.Commands.MatchInfo] does not contain a method named 'TrimStart'.
At line:1 char:90
+ ... 1,2 | foreach{ $_.TrimStart(">"," ")}
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
所有的功能都是單獨工作的,當我嘗試在最後一部分添加時,事情就會被搞砸了。
不含... ???什麼? – lit