Public/Get-GitRepositoryInfos.ps1

# Remove-Folder C:\src\Beispiele @("node_modules", "npm-cache")

#$ErrorActionPreference = 'Stop'

# https://github.com/microsoft/PowerShellForGitHub
using module "..\Private\RepositoryInfo.psm1"

function Get-GitRepositoryInfos {
  [CmdletBinding()]
  [OutputType([RepositoryInfo[]])]
  Param(
    [Parameter(Mandatory = $false,
      Position = 0,
      ParameterSetName = "ByName",
      ValueFromPipeline = $true,
      ValueFromPipelineByPropertyName = $true,
      HelpMessage = "Root path to scan sub folders.")][string[]]$Path = $pwd,
    [Parameter(Mandatory = $true,
      Position = 0,
      ParameterSetName = "ByDirectoryInfo",
      ValueFromPipeline = $true,
      ValueFromPipelineByPropertyName = $true,
      HelpMessage = "Root path to scan sub folders.")][System.IO.DirectoryInfo[]]$DirectoryInfo
  )

  begin {
    Clear-Host
    [RepositoryInfo[]]$result = @() #New-Object System.Collections.ArrayList
  }
    
  process {

    if ($DirectoryInfo) {
      $repos = $DirectoryInfo
    } else{
      $repos = Get-GitRepositories $Path
    }
  
    foreach ($item in $repos) {


      $status = Get-GitRepositoryState $item
      $commitRequired = Get-GitCommitRequired $status
      $pushRequired = Get-GitPushRequired $item

      $remoteOrigin = $(Get-GitRemoteOrigin $item)

      $currentRepo = [RepositoryInfo]@{
        Name          = $item.Name
        DirectoryInfo = $item
        State         = $status
        Commit        = $commitRequired
        Push          = $pushRequired
        RemoteOrigin  = $remoteOrigin
        Local         = [string]::IsNullOrEmpty($remoteOrigin)
        FullName      = $item.FullName
      }

      $result += $currentRepo

    }
  }
  end {
    return $result
  }
}
# Get only repos without remote: | Where-Object { $_.Local -eq $true}
# Get only repos where commit is required: | Where-Object { $_.Commit -eq $true}
# Get only repos where psuh is required: | Where-Object { $_.Push -eq $true}
# Get-GitRepositoryInfos C:\src\g-dotup | Where-Object { $_.Commit -eq $true } | Format-Table -Property Name, State, Commit, Push, Local, RemoteOrigin, FullName # c:\temp