windows 7 - Powershell equivalent of the "tail" command ALMOST works remotely -
i looking windows 7 equivalent of "tail" command , thought had found powershell equivalent -
c:\>powershell -command "& {get-content file.txt | select-object -last 100}"
if use in cmd prompt on own windows 7 pc, returns info fine. can input/append file.
however, when log on remotely pc (via openssh), command works, never drops me command prompt - hangs after showing me last 100 lines of file. means won't work batch file i'm trying edit 300 remote windows 7 pcs.
any ideas?
after trying many different suggestions found on online, found 1 worked!
and answer within batch file itself. batch file call powershell line this:
powershell.exe -noprofile -executionpolicy bypass c:\log\tail.ps1 :end
again, works great if you're using on pc want run/get information. not remotely. found need add "< nul" end of call powershell in batch file, this
powershell.exe -noprofile -executionpolicy bypass c:\log\tail.ps1 <nul :end
what other person wrote made sense: "my research has shown powershell runs commands in script indicated through -file switch , waits additional powershell commands standard input (my brief experimentation -command switch demonstrated similar behavior). redirecting standard input nul, once powershell finishes executing script , 'reads end-of-file' standard input, powershell exits."
found here @ page - powershell script gets stuck, doesn't exit when called batch file credit goes @gordon smith
Comments
Post a Comment