Last active
December 20, 2019 04:06
-
-
Save techthoughts2/c6bca351b7bf6aa8e9f7 to your computer and use it in GitHub Desktop.
PowerShell Gallery Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get the updated help | |
Update-Help -Module PowerShellGet | |
#install NuGet if not already installed | |
$testNuGet = $null | |
$nuGet = Get-PackageProvider | Select-Object -ExpandProperty Name | |
foreach($result in $nuGet){ | |
if($result -eq "NuGet"){ | |
$testNuGet = $true | |
} | |
} | |
if($testNuGet -eq $true){ | |
Write-Host "NuGet is installed" -ForegroundColor Magenta | |
} | |
else{ | |
Install-PackageProvider -Name NuGet -Force | |
} | |
#find some scripts and stuff | |
Find-Module -Repository PSGallery | |
Find-Script -Repository PSGallery | |
Find-Module -Name PSReadLine -Repository PSGallery | Get-Member | |
Find-Script -Repository PSGallery -Tag Hyper-V | |
Find-Script -Repository PSGallery -Filter Hyper-V | |
#save - but not install (inspect stuff) | |
Save-Module | |
Save-Script | |
Save-Script -Name "Fabrikam-ClientScript" -Repository PSGallery -Path "D:\ScriptSharingDemo" | |
#actually install | |
#modules: $env:USERPROFILE\Documents\WindowsPowerShell\Modules | |
#scripts: $env:USERPROFILE\Documents\WindowsPowerShell\Scripts | |
Install-Module | |
Install-Script | |
#to update installed script/module | |
Update-Module | |
Update-Script | |
#show what is currently installed | |
Get-InstalledModule | |
Get-InstalledScript | |
#publish stuff | |
Publish-Module -Name <moduleName> -NuGetApiKey <apiKey> | |
Publish-Script -Path <scriptPath> -NuGetApiKey <apiKey> | |
Publish-Script -Path "C:\rs-pkgs\Diag-V.ps1" -NuGetApiKey | |
#writing file info for a script before upload | |
Update-ScriptFileInfo -Path "C:\rs-pkgs\Diag-V2.ps1" | |
Test-ScriptFileInfo -Path "C:\rs-pkgs\Diag-V.ps1" | |
New-ScriptFileInfo -Path "C:\rs-pkgs\Diag-V.ps1" -Verbose | |
# top 50 modules | |
$allModules = Find-Module -Name * | |
$community = $allModules | ? { | |
$_.AdditionalMetadata.copyright -notlike "*Microsoft*" ` | |
-and $_.AdditionalMetadata.CompanyName -notlike "*Microsoft*" ` | |
-and $_.AdditionalMetadata.CompanyName -notlike "*Amazon.com*" ` | |
-and $_.AdditionalMetadata.copyright -notlike "*Amazon.com*" ` | |
-and $_.AdditionalMetadata.CompanyName -notlike "*VMware*" ` | |
-and $_.AdditionalMetadata.copyright -notlike "*VMware*" ` | |
} | |
$top50 = $community ` | |
| Sort-Object {[int]$_.AdditionalMetadata.downloadCount} -Descending ` | |
| Select-Object Name,@{N="Downloads";E={$_.AdditionalMetadata.downloadCount}} -First 50 | |
$top50Summary = $community ` | |
| Sort-Object {[int]$_.AdditionalMetadata.downloadCount} -Descending ` | |
| Select-Object Name,@{N="Summary";E={$_.AdditionalMetadata.summary}} -First 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment