2017-02-09 9 views
1

NodeJSがパラメータで指定した文字列をファイルから検索しようとしています。 PowerShell says $input is empty.PowerShell paramが空でない場合は

私が間違って何をやっている:

param(
    [switch]$raw, 
    [string]$input 
) 

[string]$file = "*.log" 
if($raw) { $file = ".\raws\*.log" } 

Get-ChildItem -Recurse -Include $file | select-string $input 

問題は、私は$inputが空であること、エラーを取得していますということですか?

+4

'$ input'は[自動変数](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_automatic_variables)ですあなたのコードの名前。なぜそれが壊れているのか分かりませんが、確かに誤解を招きます。 – TessellatingHeckler

+0

それは@TessellatingHecklerになります。どうもありがとうございました。 – Farcrada

+0

[$ \ _と\ [parameter(ValueFromPipeline = $ true)\]の間の奇妙な差異の可能な複製(http://stackoverflow.com/questions/13502949/strange-difference-between-and-parametervaluefrompipeline-true) –

答えて

0

$inputは予約された/自動変数であることを指摘してくれた@TessellatingHecklerのおかげで、このように使用することはできません。

関連する問題