Install Any Command Easily in PowerShell

Install-module -SkipPublisherCheck -AcceptLicense -Force -Name (find-command get-mgdomain).ModuleName -Repository PSGallery -Verbose -ErrorAction SilentlyContinue -Scope AllUsers -AllowClobber

For some reason you have to use the slightly different (get-command Connect-AzureAD).Source for other modules, like for Azure (not sure why)…

Install-module -SkipPublisherCheck -AcceptLicense -Force -Name (get-command Connect-AzureAD).Source -Repository PSGallery -Verbose -ErrorAction SilentlyContinue -Scope AllUsers -AllowClobber

Install-module -SkipPublisherCheck -AcceptLicense -Force -Name (get-command Get-Azvm).Source -Repository PSGallery -Verbose -ErrorAction SilentlyContinue -Scope AllUsers -AllowClobber

Those are the two ways you would install ANY module for a command you need; That is called intelligent installing!
Now tell me that’s not convenient? So, when you need to get just that right module for a new nodule, like MSGraph, use find-command!
NOTE: I changed the ‘-Scope’ to ‘AllUsers’ for updating the global Modules folder,
‘-CurrentUser’ updates only your Modules folder in only your profile path.


Posted

in

, , , ,

by

Comments

2 responses to “Install Any Command Easily in PowerShell”

  1. PatrickBurwell Avatar
    PatrickBurwell

    Drat:

    update-help -Force -Name (find-command connect-viserver).ModuleName

    ‘The Update-Help command failed because the specified module does not support updatable help. Use Get-Help -Online or look online for help for the commands in this module.’

    < Well at least this is how to install PowerCLI in your own PowerShell environment without the need for downloading PowerCLI as an install

  2. PatrickBurwell Avatar
    PatrickBurwell

    Don’t forget to turn off this noise in PowerCLI:

    Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCEIP $false -Confirm:$false -DefaultVIServerMode Multiple -InvalidCertificateAction unset -Verbose