GithubHelp home page GithubHelp logo

psmodulemanager's Introduction

PSModuleManager - PowerShell Module

PSModuleManager it's the module for managing PowerShell modules on your machine. The module is based on native cmdlets like Get-Module, Update-Module, and Uninstall-Module.

PSModuleManager provides 3 functions that help you get a list of modules depends on a scope (CurrentUser, AllUsers or System), removing older versions, and updating to the latest versions in a fast way.

I recommend PowerShell Modules in a Cross-Version World post, which a good explains the location for modules in Windows PowerShell and Powershell 7.

โš ๏ธ The module requires administrator permission

Get-PSInstalledModule

The function returns information about available modules on your machine (similar to Get-Module and Get-InstalledModule). Default it will be modules from CurrentScope scope (and consistent with running PowerShell version).

A whole object that it's returned:

Get-PSInstalledModule -Name dbatools  | Select-Object *

# Name          : Az
# LatestVersion : 5.3.0
# Count         : 1
# Modules       : {@{Name=Az; Version=5.3.0; Scope=AllUsers; ModuleBase=C:\Program Files\PowerShell\Modules\Az\5.3.0; SpaceUsed=43563; PowerShellVersion=5.1}}
# Scope         : AllUsers
# SpaceUsedMb   : 0,04
# Description   : Microsoft Azure PowerShell - Cmdlets to manage resources in Azure. This module is compatible with WindowsPowerShell and PowerShell Core. For more information about the Az module, please visit the following: https://docs.microsoft.com/en-us/powershell/azure/
# Author        : Microsoft Corporation
# CompanyName   : Microsoft Corporation

Examples

You can get information about all modules on your machine (example for Windows PowerShell if the command will be running there)

# default CurrentUser scope
Get-PSInstalledModule

# the command for AllUsers scope
Get-PSInstalledModule -Scope AllUsers

# the command for System scope
Get-PSInstalledModule -Scope System

Get-PSInstalledModule

You can get information about one a module.

Get-PSInstalledModule -Name dbatools

# a parameter -Name supports wildcards
Get-PSInstalledModule -Name dba*

You can get information about how many space use for installed modules

# CurrentUser scope
Get-PSInstalledModule | Measure-Object -Property SpaceUsedMb -Sum

# AllUsers scope
Get-PSInstalledModule -Scope AllUsers | Measure-Object -Property SpaceUsedMb -Sum

Other examples

Get-PSInstalledModule | Sort-Object -Property SpaceusedMb -Descending | Select -First 5

Get-PSInstalledModule -Scope AllUsers | Sort-Object -Property SpaceusedMb -Descending | Select -First 5

Get-PSInstalledModule | Sort-Object -Property Count -Descending | Select -First 5

Get-PSInstalledModule -Scope AllUsers | Sort-Object -Property Count -Descending | Select -First 5

Update-PSModule

The command wraps Update-Module cmdlet. Update-PSModule needs a ModuleManagerList object from Get-PSIntalledModule.

# updating all modules for CurrentUser scope
Get-PSInstalledModule | Update-PSModule -Force

Update-PSModule

Examples

# the command supports -WhatIf switch
Get-PSInstalledModule -Name dbatools -Scope AllUsers | Update-PSModule -WhatIf

# updating all modules for AllUsers scope
Get-PSInstalledModule -Scope AllUsers | Update-PSModule -Verbose -Force

# updating Az.Accounts module
Get-PSInstalledModule -Name Az.Accounts | Update-PSModule -Force

# updating modules matching regular expression
Get-PSInstalledModule -Name az* | Update-PSModule -Force

Uninstal-PSOlderModule

The command wraps the Uninstall-Module cmdlet. UninstalPSOlderModule needs an object ModuleManagerList from Get-PSIntalledModule and uninstalls all older versions.

# removing old versions for modules in the scope of CurrentUser
Get-PSInstalledModule | Uninstall-PSOlderModule

Examples

# you can use -WhatIf switch
Get-PSInstalledModule -Scope AllUsers | Uninstall-PSOlderModule -Verbose -WhatIf

Get-PSInstalledModule -Name dbatools -Scope AllUsers | Uninstall-PSOlderModule -Verbose -WhatIf

# removing older versions Az.Accounts module
Get-PSInstalledModule -Name Az.Accounts | Uninstall-PSOlderModule

# removing older versions for modules in the scope of AllUsers
Get-PSInstalledModule -Scope AllUsers | Uninstall-PSOlderModule

# removing older versions for the selected module in AllUser scope
Get-PSInstalledModule -Name dbatools -Scope AllUsers | Uninstall-PSOlderModule -Verbose

Installation

Install from PSGallery

Install-Module -Name PSModuleManager -Force

Update from PSGallery

Update-Module -Name PSModuleManager

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.