In previous post, we discussed PowerShellGet versus PackageManagement/OneGet.
Now that we have a better understanding of what PowerShellGet is all about, let’s have a look at the cmdlets in the PowerShellGet module.
Using the PowerShellGet module, you can:
- Search online through items (modules, scripts, DSC resources) in the Gallery with Find-Module, Find-Script and Find-DscResource
- Save items to your system from the Gallery with Save-Module and Save-Script
- Install items from the Gallery with Install-Module and Install-Script
- Upload items to the Gallery with Publish-Module and Publish-Script
- Add your own custom repository with Register-PSRepository
PowerShellGet allows unified management of PowerShell modules, scripts and DSC resources.
Find cmdlets (Module, Script, DSCResource)
The find cmdlets search online through items (module, script, DSC resource) in an online gallery. By default, that is the PowerShell Gallery.
These items include:
- Module
- Script
- DSC Resource
Install cmdlets (Module, Script)
The install cmdlets download one or more items from an online gallery and installs them on the local computer. By default, that is the PowerShell Gallery.
These items include:
- Module
- Script
The install cmdlets (Install-Script, Install-Module) operate against the default PS repository, but are configurable through the Register-PSRepository, Set-PSRepository, Unregister-PSRepository and Get-PSRepository cmdlets.
When operating against multiple repositories, Install-Script installs the first script that matches the specified search criteria (Name, MinimumVersion, or MaximumVersion) from the first repository without any error.
By default, these installed items live in “C:\Program Files\WindowsPowerShell”.
Save cmdlets (Module, Script)
The save cmdlets download one or more items from an online gallery without installing them on the local computer. By default, that is the PowerShell Gallery.
These items include:
- Module
- Script
Get cmdlets (InstalledModule, InstalledScript)
The get cmdlets retrieve a list of the installed items (by PowerShellGet Install-Module, Install-Script ) on the local computer.
These items include:
- Installed Module
- Installed Script
For module items, this information is retrieved from the file “PSGetModuleInfo.xml” in each module folder.
For script items, this information is retrieved from the file “<script>_InstalledScriptInfo.xml”.
The overview of installed modules as a result of using the Install-Module cmdlet.
Update cmdlets (Module, Script)
The update cmdlets download and install the newest version of specified modules from an online gallery to the local computer. By default, that is the PowerShell Gallery.
These items include:
- Module
- Script
Uninstall cmdlets (Module, Script)
The uninstall cmdlets uninstall items on the local computer.
These items include:
- Module
- Script
Publish cmdlets (Module, Script)
The publish cmdlets publish specified items from the local computer to an online gallery. By default, that is the PowerShell Gallery.
These items include:
- Module
- Script
Publishing a module and/or script requires metadata that is displayed on the gallery page for the module.
The required metadata includes the module name, version, description and author.
Although most metadata is taken from the module manifest, some metadata must be specified in Publish-Module parameters, such as Tag, ReleaseNote, IconUri, ProjectUri and LicenseUri.
We will cover publishing scripts and module to the PowerShell Gallery in another blog post.
PowerShell Repository cmdlets
The PSRepository cmdlets provide management of the PowerShell repositories.
These repositories may be public or private, accessible via the internet or only accessible on an internal network.
These cmdlets include:
- Get-PSRepository
- Set-PSRepository
- Register-PSRepository
- Unregister-PSRepository
Each registered repository is associated with a package provider, which is specified in the “PackageManagementProvider” property.
Each provider is designed to interact with a specific type of repository. For example, the NuGet provider is designed to interact with NuGet-based repositories.
Each registered repository has an installation policy and specifies PowerShell behavior when installing items from that repository.
When installing items (modules/script) from an Untrusted repository, the user is prompted for confirmation.
Each registered repository has a URI for discovering and installing modules from this repository.
For example, for NuGet-based repositories, the source location is similar to http://someNuGetUrl.com/api/v2/.
NOTE: PowerShellGet also contains other cmdlets relating to
- Working with roles and role capabilities in JEA (Just Enough Admin)
Related reading:
One thought on “PowerShellGet – Package Management for PowerShell modules – Part 2”