Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

 Windows OS Hub / Windows 10 / Using PowerShell PackageManagement In Windows 10

June 15, 2017 Windows 10Windows Server 2016

Using PowerShell PackageManagement In Windows 10

The developers have included a new PowerShell module PackageManagement in Windows 10. PackageManagement (earlier called OneGet) allows to install, manage and uninstall applications and programs from an external (or local) repository, and manage the list of connected repositories from the PoSh console. In other words, now you can install programs from the command prompt in Windows 10/ Windows Server 2016 like they do it in Linux using the well-known command apt-get install.

The PackageManagement module makes it easy to install new software. The installation comes down to running a single PowerShell command, and a user doesn’t have to search and download software distributions in the Web, thus reducing the risk of downloading an outdated or infected programs. Software is installed from a trusted source. When software is updated in a repository, it can be automatically updated on the clients.

Contents:
  • PackageManagement Module
  • Package Providers
  • Installing applications from the Chocolatey repository
  • How to Uninstall a Package

PackageManagement Module

PackageManagement module is already integrated in Windows 10, and it requires PowerShell 5. To make PackageManagement work under Windows 8.1, you will have to install Windows Management Framework 5.0 first. Microsoft has also issued a separate PackageManagement module to work in PowerShell v.3 and 4.

Display the list of available PowerShell cmdlets in PackageManagement module:

Get-Command -Module PackageManagement

In the current version of the module (v 1.0.0.1) the following commands are available:

  • Find-Package – search a package (program) in the available repositories
  • Get-Package – show a list of installed packages
  • Get-PackageProvider – display the list of package providers available on the computer
  • Get-PackageSource – list available package sources
  • Install-Package – install a package (program) on the computer
  • Register-PackageSource – add a package source for the provider
  • Save-Package – save a package locally without installing it
  • Set-PackageSource – set a provider as a package source
  • Uninstall-Package – uninstall a program (package)
  • Unregister-PackageSource – remove a provider from the list of package sources

Get-Command -Module PackageManagement

Package Providers

Packages are serviced by different providers that can receive packages from different sources. To display the list of available providers, run this command:

Find-PackageProvider

Find-PackageProvider

By default, there are two installed package sources in the system: nuget.org and PSGallery (official online gallery of PowerShell scripts from MSFT). First of all, they are designed for programmers and system administrators.

Note. In Nano Server, there is a special provider NanoServerPackage that will be discussed in the next article.

To access the application software repository, let’s connect a popular software repository – Chocolatey containing over 4,500 different programs.

Install a new provider, Chocolatey:

Install-PackageProvider chocolatey

Confirm the provider installation by pressing Y.

Install-PackageProvider chocolatey

Make Chocolatey a trusted package source in order not to confirm package installation each time.

Set-PackageSource -Name chocolatey -Trusted

Make sure that Chocolatey is now available among the application repositories:

Get-PackageSource

Get-PackageSource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2/
chocolatey                       Chocolatey       True      http://chocolatey.org/api/v2/

Installing applications from the Chocolatey repository

Let’s see how to install an application (a package) from Chocolatey.

A list of available applications can be obtained directly from the official Chocolatey website (https://chocolatey.org/packages)

Chocolatey repository website

You can also find and install an apps right from the PowerShell console. For example, to view PDF files we have to install Adobe Acrobat Reader. Since we don’t know the full name of the application, we needed to get the name of the package in the directory to install it. Search the repository by the keyword “adobe”:

Find-Package -Name *adobe* -Source Chocolatey

The list of all packages containing this keyword will appear in the console. We need adobereader (it is the package name from the Name column that we need to use).

Run the installation of Adobe Reader package:

Install-Package -Name adobereader -ProviderName Chocolatey

Install-Package -Name adobereader -ProviderName Chocolatey

On the top of PowerShell window, a slider will appear that indicates that Adobe Reader package is being downloaded. Immediately after the download is completed, the application is installed on the system.

Installed Adobe Reader DC

Another example. Suppose, you need a set of tools SysInternals. In order not to download it manually, find SysInternals package in Chocolatey and install it.

Find-Package -Name Sysinternals | Install-Package

Since the package doesn’t need any installation, it is saved to your computer and stored in C:\Chocolatey\lib\. In our example, it is C:\Chocolatey\lib\sysinternals.2016.11.18\tools

install Sysinternals tools from chokolatey

You can install several applications at a time using a single command:

Find-Package -Name firefox, winrar, notepadplusplus, putty, dropbox | Install-Package

How to Uninstall a Package

You can also uninstall a package using just a single command. For example, to uninstall Adobe Reader run this command:

Uninstall-Package adobereader

So, we have considered a new ways to install Windows applications from the PowerShell command prompt. In the nearest future, graphical add-ins for PackageManagement may appear that allow to easily manage installation/uninstallation of software for common users without CLI skills.

2 comments
0
Facebook Twitter Google + Pinterest
previous post
Outlook: How to Delete E-Mails Stuck in Outbox
next post
Managing Disconnected Mailboxes in Exchange Server

Related Reading

How to Troubleshoot, Repair and Rebuild the WMI...

March 2, 2021

How to Sign a PowerShell Script (PS1) with...

February 25, 2021

How to Shadow (Remote Control) a User’s RDP...

February 22, 2021

Configuring PowerShell Script Execution Policy

February 18, 2021

Configuring Proxy Settings on Windows Using Group Policy...

February 17, 2021

2 comments

Rack November 17, 2018 - 6:08 pm

Hi, I have a new install of windows 10 October 2018 with powershell 5, developper mode is activate. and I haven’t the PackageManagement
Get-Command -Module PackageManagement display nothing
(i try to found this for psreadline and history command)
I have already install chocolatey it works without problem
Get-execution policy give

Scope ExecutionPolicy
—– —————
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned

If you have a solution i’m interested.^^

Reply
Scott Bastoky March 13, 2020 - 4:55 pm

C:\Chocolatey\lib\sysinternals.2016.11.18\tools

Directory not found past Chocolatey

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • How to Troubleshoot, Repair and Rebuild the WMI Repository?

    March 2, 2021
  • Accessing USB Flash Drive from VMWare ESXi

    February 26, 2021
  • How to Sign a PowerShell Script (PS1) with a Code Signing Certificate?

    February 25, 2021
  • Change the Default Port Number (TCP/1433) for a MS SQL Server Instance

    February 24, 2021
  • How to Shadow (Remote Control) a User’s RDP session on RDS Windows Server 2016/2019?

    February 22, 2021
  • Configuring PowerShell Script Execution Policy

    February 18, 2021
  • Configuring Proxy Settings on Windows Using Group Policy Preferences

    February 17, 2021
  • Updating Group Policy Settings on Windows Domain Computers

    February 16, 2021
  • Managing Administrative Shares (Admin$, IPC$, C$, D$) in Windows 10

    February 11, 2021
  • Packet Monitor (PktMon) – Built-in Packet Sniffer in Windows 10

    February 10, 2021

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Booting Windows 7 / 10 from GPT Disk on BIOS (non-UEFI) systems
  • Removable USB Flash Drive as Local HDD in Windows 10 / 7
  • How to Create a Wi-Fi Hotspot on your Windows 10 PC
  • How to increase KMS current count (count is insufficient)
  • How to Download APPX Installation File from Microsoft Store in Windows 10 / 8.1
  • How to Sign an Unsigned Driver for x64 Windows 10, 8.1 or 7 with a Self-signed Certificate
  • How to Hide Installed Programs from Programs and Features in Windows?
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top