This is one of those posts I’m doing mostly for myself to keep things in one place.
Remove an old version of a module:
$Latest = Get-InstalledModule (modulename); Get-InstalledModule (modulename) -AllVersions | ? {$_.Version -ne $Latest.Version} | Uninstall-Module -WhatIf
another way to do the same:
get-installedmodule modname -requiredversion x.x.x | uninstall-module
(taken from https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/14934876-update-module-needs-flag-to-remove-previous-versio)
Show what modules are installed:
get-installedmodule
Show what versions of a specific module are installed
get-installedmodule -name modname -allversions
Update the azureRM module:
update-module azurerm -force
Install over a stubborn module:
install-module azurerm.cognitiveservices -force