Matt Canty
Matt Canty

Reputation: 2465

Using Powershell parameters in pipe command

I have this Powershell script which iterates through this folder's directories and runs git log.

However I cannot figure out how to get the $author parameter through to the git command.

Param(
  [string]$author,
  [string]$since
)
Get-ChildItem | ? { $_.PSIsContainer } | % { Push-Location $_.FullName; Write-Host "--" (Get-Location);`
git --no-pager log --author=$author --since='1 friday ago' --until='now' --format='%Cgreen%cr%Creset %s%Creset' --graph --decorate;`
Pop-Location }

Upvotes: 0

Views: 641

Answers (1)

Enrico Campidoglio
Enrico Campidoglio

Reputation: 59913

Given this script:

# Log.ps1
Param(
    [string]$author
)

Get-ChildItem -Directory | % { Push-Location $_.FullName; git --no-pager log --author=$author; Pop-Location }

Invoking it like this yields the correct result:

.\Log.ps1 "SomeAuthor"

Upvotes: 1

Related Questions