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.
Comments
2 responses to “Install Any Command Easily in PowerShell”
Drat:
update-help -Force -Name (find-command connect-viserver).ModuleName
< Well at least this is how to install PowerCLI in your own PowerShell environment without the need for downloading PowerCLI as an install
Don’t forget to turn off this noise in PowerCLI:
Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCEIP $false -Confirm:$false -DefaultVIServerMode Multiple -InvalidCertificateAction unset -Verbose