Interacting with repositories

Working with external dependencies is easy due to modules such as PackageManagement, which allow the bootstrapping of all the necessary components of a module or script on the fly:

# Module cmdlets
Get-Command -Module PackageManagement

# Interacting with repositories

# You have different package sources that you can add and remove
Get-PackageSource

# These sources are powered by different providers
Get-PackageProvider

# In order to find packages, narrow down by provider
# You can locate binary packages
Find-Package -Name notepadplusplus -ProviderName Chocolatey

# and PowerShell modules
Find-Package -Name AutomatedLab -ProviderName PowerShellGet

Installing packages with PackageManagement is very easy. The package cmdlets provide a central entry point for different providers, such as NuGet, Chocolatey, Docker registries, AppX packages, and others:

# When interacting with package providers, you can install specific versions
# and additional providers
Install-PackageProvider -Name nuget -MinimumVersion 2.8.5.208
Find-PackageProvider

# Installing packages is straightforward
Find-Package -Name AutomatedLab,notepadplusplus | Install-Package
Install-Package -Name datum

You can always save packages before installing them to examine the contents more closely before committing to any changes in your infrastructure:

# Save package to inspect its contents
Save-Package notepadplusplus -Path . pp -Force -Verbose

Lastly, you can always remove previously installed packages. The removal process depends on the specific provider. PowerShell modules will simply be removed, while MSI packages will be uninstalled:

# Remove previously installed packages
Uninstall-Package -Name notepadplusplus
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset