Reputation: 57
I have prepared a PowerShell script in PS 3.0 and when I am executing it in PS 2.0 I am getting an error saying "A positional parameter cannot be found that accepts the argument -tail".
The same command is being executed well in PS 3.0. Below is my command.
get-content '\\mtrlpqdc2c4-035\D$\HPBSM\log\odb\jvm_statistics.log' -Tail 1
Is there any other parameter that I can use instead of "-Tail"
Upvotes: 1
Views: 3513
Reputation: 19684
No, Get-Content
did not add the Tail
parameter until v3.
A fast workaround:
(Get-Content -Path $path)[-1]
I believe Tail
does not gather the content of the entire file and select n
lines like my workaround does, so this method will be significantly slower on a large enough file unless you implement your own method of getting the end of a file.
Upvotes: 3