
명령
systeminfo | find "System Type"
돌아올 예정이다
System Type: x64-based PC
명령 프롬프트 창과 PowerShell 모두에서.
내 경우에는
/usr/bin/find: 'System Type': No such file or directory
왜냐면 위에서 설명했듯이https://github.com/MicrosoftDocs/WSL/issues/1025, 나 find
안에 또 하나 있어요시그윈그것은 내 길에 있습니다.
이 경우 올바르게 작동하는 것은
systeminfo | c:\windows\system32\find.exe "System Type"
이제 시스템이 있는 위치와 독립적으로 만들고 싶다고 가정해 보겠습니다(예를 들어 부주의한 사용자를 위한 가이드에 이 명령을 포함하려는 경우). 대신 호출하려고 생각했습니다.
systeminfo | %SystemRoot%\system32\find.exe "System Type"
이는 명령 프롬프트에서는 작동하지만 PowerShell에서는 작동하지 않습니다. 후자에서는 시도했습니다.
systeminfo | $env:SystemRoot\system32\find.exe "System Type"
하지만 이것은 오류를 발생시킵니다
Expressions are only allowed as the first element of a pipeline.
전체 경로를 수행했지만 없이 수행하면 오류가 발생합니다 .exe
.
systeminfo | c:\windows\system32\find "System Type"
준다
Cannot run a document in the middle of a pipeline: C:\windows\system32\find
나도 시도했다
systeminfo | % $env:SystemRoot\system32\find.exe "System Type"
하지만 이로 인해 다음과 같은 오류가 발생합니다.
% : Input name "C:\WINDOWS\system32\find.exe" cannot be resolved to a method.
무슨 일이야? 올바르게 수행하는 방법은 무엇입니까?
답변1
당신은 할 수 있습니다 :
systeminfo | & $env:SystemRoot\system32\find.exe "System Type"
명령 앞에 앰퍼샌드를 적어 두십시오.
그러나 더 나은 방법은 PowerShell이 아닌 출력을 PowerShell이 아닌 프로그램으로 파이프하는 대신 기본 PowerShell을 사용하는 것입니다.
(Get-ComputerInfo -Property CsSystemType).CsSystemType