We have script which is normally executed within a unix environment. The following is a line from the script:
command => 'use/bin/tail -n 1 %{path} | grep --silent -F "%{message}" && rm -f {path}'
When run within PowerShell, the use/bin/tail
path is obviously not recognized. As an alternative I tried this:
command => 'Get-Content -n 1 %{path} -Tail | grep --silent -F "%{message}" && rm -f {path}'
However, while Get-Content
is recognized when run from the PowerShell command line itself, it is not recognized when run from within the script.
This is the error message:
'Get-Content' is not recognized as an internal or external command, operable program or batch file.
What is the correct way to replicate the unix tail
command when running a script in PowerShell?