Category filter

Script to install/uninstall packages on Windows

Users normally download and install software packages (or software upgrades) from the download links available on websites. Because it is tedious enough to trawl countless websites to get the packages, Windows offers a package manager solution named Windows Package Manager to help us install and manage different software packages from the command line. It is a faster and more seamless method for installing packages. Users can create scripts using the commands contained in the PacketManagement module to install packages on their Windows devices. Hexnode UEM offers IT admins the Execute Custom Script action to remotely deploy these scripts to their Windows 10/11 devices. This action allows for packages to be downloaded and installed on devices without the need for user intervention.


The sample scripts provided below are adapted from third-party open-source sites.

PowerShell script to install package

The script uses the Install-Package cmdlet with two parameters, Name and Source, to install a software package. Name is used to specify the name of the package, while Source specifies the name of the source/repository where the package is stored.

For example, the script looks like this when installing the Carbon app from the package source PSGallery:

Install-Package -Name Carbon -Source PSGallery –Force

Because the packages are stored in repositories called package sources, you could use the Get-PackageSource command to get the complete list of package sources that are available for the endpoint.

PowerShell script to find a software package and install it

The Find-Package cmdlet is used to find software packages in available package sources. Admin must specify the name of the package in the command to achieve this. The Install-Package cmdlet then installs the found package.

For example, the following sample script installs a package named Gac by piping the package fetched using the Find-Package command:

Find-Package “Gac” | Install-Package

PowerShell script to install packages by specifying a range of versions

To give an example, we can install the latest version of the Az.Billing package among a range of versions by specifying the MinimumVersion and MaximumVersion parameters in the Install-Package cmdlet:

Install-Package -Name “Az.Billing” -MinimumVersion 1.0.1 -MaximumVersion 1.0.3

PowerShell script to uninstall package

For uninstallation of a package, use the Uninstall-Package cmdlet and specify the name of the package.

To give an example, Carbon app can be uninstalled from the device using the command:

Uninstall-Package -Name Carbon


  • Make sure your Windows 10/11 computer system is connected to the internet during script deployment.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository