I have a few scripts where I import all VMware-Modules for simplicity. This has worked all the time - but now on one server it won't.
PS C:\Temp> Import-Module VMware.*
Import-Module : The specified module 'VMware.*' was not loaded because no valid module file was found in any module
directory.
At line:1 char:1
+ Import-Module VMware.*
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (VMware.*:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
I just copied the modules to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
.
When I use the full name (Import-Module VMware.VimAutomation.Core
) it works as usual.
How can I fix this? They appear correctly when I do a Get-Module -ListAvailable
.
Import-Module
doesn't support wildcards. What you could do, however, is get all the module names usingGet-Module
and then pipe them into aForEach-Object
command.I believe this will achieve what you are after: