Getting stdin into the Powershell stream
<p>The following script works well when the filename is specified on the command line.</p>

tail.bat

<pre><code>@echo off
set "COUNT=%1"
set "COUNT=%COUNT:-=%"
set "FILENAME=%~2"
powershell "Get-Content %FILENAME% -Last %COUNT%"
</code></pre>

<p>However, what I need is to be able to pipe the text into <code>Get-Content</code> from stdin. I would like to write the following to get the last three Subversion tags assigned to the project. What can I do to get the source to <code>Get-Content</code> to be stdin?</p>

<pre><code>svn ls svn://ahost/arepo/aproject/tags | call tail.bat -3
</code></pre>

<p>NB: I am not permitted to install any helpful tools like <code>tail</code> from the outside. It has to be done with the programs already available on the machine.</p>

<p><strong>Update:</strong></p>

<p>@mklement0 provided the answer. From that, I added code to use a default COUNT value of 10 if it is not provided. This matches the UNIX/Linux way.</p>

<pre><code>@echo off

SET "COUNT=%~1"
IF "%COUNT:~0,1%" == "-" (
    SET "COUNT=%COUNT:~1%"
    SHIFT
) ELSE (
    SET "COUNT=10"
)
SET "FILENAME=%~1"

if "%FILENAME%" == "" (
    powershell -noprofile -command "$Input | Select-Object -Last %COUNT%"
) else (
    powershell -noprofile -command "Get-Content \"%FILENAME%\" -Last %COUNT%"
)

EXIT /B
</code></pre>