@@ -33,6 +33,9 @@ function Find-NugetPackage {
3333 PSGallery Module URL: https://www.powershellgallery.com/api/v2/ (default)
3434 PSGallery Script URL: https://www.powershellgallery.com/api/v2/items/psscript/
3535
36+ . PARAMETER Credential
37+ Use if repository requires basic authentication
38+
3639 . EXAMPLE
3740 Find-NugetPackage PSDepend -IsLatest
3841
@@ -65,7 +68,9 @@ function Find-NugetPackage {
6568 # If specified takes precedence over version
6669 [switch ]$IsLatest ,
6770
68- [string ]$Version
71+ [string ]$Version ,
72+
73+ [PSCredential ]$Credential
6974 )
7075
7176 # Ugly way to do this. Prefer islatest, otherwise look for version, otherwise grab all matching modules
@@ -84,8 +89,16 @@ function Find-NugetPackage {
8489 Write-Verbose " Searching for all versions of [$name ] module"
8590 $URI = Join-Part - Separator / - Parts $PackageSourceUrl , " Packages?`$ filter=Id eq '$name '"
8691 }
92+
93+ $params = @ {
94+ Uri = $Uri
95+ }
96+
97+ if ($PSBoundParameters.ContainsKey (' Credential' )){
98+ $Params.add (' Credential' , $Credential )
99+ }
87100
88- Invoke-RestMethod $URI |
101+ Invoke-RestMethod @params |
89102 Select-Object @ {n = ' Name' ;ex = {$_.title .(' #text' )}},
90103 @ {n = ' Author' ;ex = {$_.author.name }},
91104 @ {n = ' Version' ;ex = {
@@ -98,4 +111,4 @@ function Find-NugetPackage {
98111 @ {n = ' Uri' ;ex = {$_.Content.src }},
99112 @ {n = ' Description' ;ex = {$_.properties.Description }},
100113 @ {n = ' Properties' ;ex = {$_.properties }}
101- }
114+ }
0 commit comments