I wan to remove all imported modules before importing them so that I can get the fresh ones by overwriting the ones in the memory.
How can I remove all imported modules in PowerShell?
Thanks
If you have multiple versions of the same module installed in the PowerShell, and if you want to uninstall all of them then use the -AllVersions Parameter. If you want to uninstall the specific version, we can use -RequiredVersion. To uninstall on the remote computer, use the Invoke-Command method.
VERBOSE: Removing imported function 'Get-LogProperties'. VERBOSE: Removing imported function 'Enable-PSTrace'. VERBOSE: Removing imported function 'Disable-PSTrace'. VERBOSE: Performing operation "Remove-Module" on Target "PSDiagnostics (Path: 'C:\Windows\system32\WindowsPowerShell\v1.
The Remove-Module cmdlet removes the members of a module, such as cmdlets and functions, from the current session. If the module includes an assembly (. dll), all members that are implemented by the assembly are removed, but the assembly is not unloaded.
this should do it:
get-module | Remove-Module
this remove also imported modules in $profile
.
More about this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With