PowerShell Core for Linux Administrators Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it…

We will start by finding cmdlets that work with modules, and proceed to work with these modules:

  1. Launch PowerShell by running pwsh on the Terminal.
  2. Look for commands that work with modules:
PS> get-command -no module PS> # Verbose version: Get-Command -Noun 'Module'

The output should look something like this:

Pick Find-Module for this task. If you would like to, use the Get-Help cmdlet to learn about what Find-Module does.

  1. Search for a module to help you work with Docker containers:
  1. Now, install the module. You will need to use superuser privileges to install the Docker module. Use the following command to install Docker without having to exit the current PowerShell session:
PS> sudo pwsh -c install-module docker

If you would rather use a new session and call the Install-Module cmdlet from within it, terminate the current PowerShell session and launch a new one with sudo:

  1. To update a module, use the Update-Module cmdlet:
PS> Update-Module docker
  1. To uninstall a module from the machine, use the Uninstall-Module cmdlet:
PS> Uninstall-Module docker

  1. To load a certain module into the current session, use the Import-Module cmdlet. You do not need elevated privileges to load or unload a module to or from the session:
PS> Import-Module docker
  1. To remove a module from the session, use the Remove-Module cmdlet:
PS> Remove-Module docker