Skip to content

Instantly share code, notes, and snippets.

@lucax88x
Created January 29, 2024 17:15
Show Gist options
  • Save lucax88x/df86f70634c3f0a9a13fdc4f37a2c6c5 to your computer and use it in GitHub Desktop.
Save lucax88x/df86f70634c3f0a9a13fdc4f37a2c6c5 to your computer and use it in GitHub Desktop.
filter-nuget.ps1
function FilterNugetPackages
{
param (
[string[]]$Nugets,
[string]$Include = '',
[string]$Exclude = ''
)
if ($Include -eq "" -and $Exclude -eq "")
{
return $Nugets
}
if ($Include -ne "" -and $Exclude -ne "")
{
return $Nugets | Where-Object { $_ -match $Include -and $_ -notmatch $Exclude }
}
if ($Include -ne "")
{
return $Nugets | Where-Object { $_ -match $Include }
}
return $Nugets | Where-Object { $_ -notmatch $Exclude }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment