Skip to content

Instantly share code, notes, and snippets.

@markwragg
Last active August 10, 2024 22:47
Show Gist options
  • Save markwragg/831afb7d3fd61a0338f851f4190761df to your computer and use it in GitHub Desktop.
Save markwragg/831afb7d3fd61a0338f851f4190761df to your computer and use it in GitHub Desktop.
Find PowerShell modules for a specified author and return download count, description, URI and published date
function Find-ModuleByAttribute {
[cmdletbinding()]
param(
$Attribute = 'companyname',
$Value = 'markwragg'
)
Write-Verbose "Finding all modules where $Attribute = $Value.."
$Modules = Find-Module | Where-Object { $_.$Attribute -eq $Value }
foreach ($Module in $Modules) {
Write-Verbose "Finding all versions of $($Module.Name).."
$ModuleVersions = Find-Module -Name $Module.Name -AllVersions
$FirstPublishedDate = ($ModuleVersions | Sort-Object { $_.Version -as [version] } | Select -First 1).PublishedDate
$DownloadCount = [int]($ModuleVersions.AdditionalMetadata.versionDownloadCount | Measure-Object -Sum).Sum
[PSCustomObject]@{
Name = $Module.Name
DownloadCount = $DownloadCount
Description = $Module.Description
ProjectUri = $Module.ProjectUri
FirstPublishedDate = $FirstPublishedDate
LastPublishedDate = $Module.PublishedDate
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment