psftp "ls"명령의 출력에 대해 일부 처리를 시도하고 있습니다. 기본적으로, 특정 조건과 일치하는 모든 파일 이름을 배열에 넣고 싶습니다.PowerShell 파이프 라인 단순화 명령 출력에서 데이터 분할
가 가 이가 (.. 당신이 명령에 대한 자세한 내용을 원한다면, 내가 그들을 제공 할 수있는 출력은 PowerShell의 "LS"명령의 출력과 매우 유사)
는 것 같다
PS C:\path\to\pwd> $a = & "C:\Program Files (x86)\PuTTY\psftp.exe" -l myusername -batch -pw mypassword -b sftpbatch.txt myserver | where {$_.split(" ", [StringSplitOptions]'RemoveEmptyEntries')[0] -eq "-rw-r--r--"} | select-object {$_.split(" ", [StringSplitOptions]'RemoveEmptyEntries')[8]}
:이 있습니다 나에게 먼저 분할을 선택하고 그 다음으로 필터링하여 더 잘할 수 있습니다. 나는이 때 :
$a = & <# ... #> | select-object {$_.split(" ", [StringSplitOptions]'RemoveEmptyEntries')} | where { $_[0] -eq "-rw-r--r--" }
나는
Unable to index into an object of type System.Management.Automation.PSObject.
내가이를 단순화 할 수 있습니다 어떻게 얻을?
아마'psftp.exe'ss에서 정규식을 실행해야합니다. tdout. 명령 출력을 게시하고 추출 할 텍스트를 지정하십시오. –