I installed 6.5.1 using PowerShellGallery on a working machine. Works fine. I copied the module folders from that machine to another machine that cannot use PowerShellGallery and I cannot get it to find or load the modules. I tried the following locations:
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\System32\WindowsPowerShell\Modules
C:\Users\MyAccount\Documents\WindowsPowerShell\Modules
None of these locations work.
One thing I noticed is that there is an extra directory level under each PowerCLI module folder. For example in VMware.PowerCLI there is another folder called "6.5.1.5377412" before it gets to the module files. Is that extra folder causing a problem?
Or do I need PS 5.x? On the machine I downloaded it with and is working, I have PS 5.1. All my other machines that are failing are PS 4.0.
Any suggestions?
Thanks
NK
Problem solved. If you use PowerShellGallery to install PowerCLI on a PS 4 machine, it does not create the middle versioning folder:
C:\Program Files\WindowsPowerShell\Modules\VMware.PowerCLI\6.5.1.5377412
Instead it puts the module files right under the module folder:
C:\Program Files\WindowsPowerShell\Modules\VMware.PowerCLI
So the trick is to use a PS 4 machine to download from PowerShellGallery to create the offline files to be used with other PS4 machines (or manually remove the version folder from the PS 5.x downloads before copying to PS 4 machines).
NK
Did you check the $env:PSModulePath variable?
Does it contain the folder where you copied the PowerCLI modules?
PowerCLI 6.5.1 will run on PowerShell v3, v4 and v5.
The subfolder with the version number is ok.
The installation process is a bit different when you're not on PowerShell v5.
When you're online, see See PowerCLI 6.5.1 Installation Walkthrough (around the 4:25 mark).
When you're not online, you can copy the files (like you did), but make sure the $env:PSModulePath allows PS to find the modules.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for the reply.
Everything looks correct on my end, from what I can tell. Here is a screenshot.
This looks pretty much identical to the machine that is working, except there is PackageManagement and PowerShellGet module folders along with the ones in the screenshot above, since it is a PS 5.1 machine, and of course the Connect-VIServer cmdlet does not product an error.
Thanks
NK
I found another machine running PS 5.1 and used the offline copy process to get the PowerCLI modules on to it - I did not use the PowerShellGallery method...and it works perfectly.
So something is up with PS 4 and the new PowerCLI (at least using the copy/offline method). I have tried multiple machines, and they all fail. Windows 2008 R2 and Windows 2012 R2 - all running PS 4.
Has anyone gotten the offline method to work with PS 4?
Thanks
NK
From what I can tell, PS 4.0 does not like sub-folders in the module folder.
PS 5.1 - this works:
C:\Program Files\WindowsPowerShell\Modules\MyTestModule\1.0\MyTestModule.psm1
PS 4.0 - this fails:
C:\Program Files\WindowsPowerShell\Modules\MyTestModule\1.0\MyTestModule.psm1
And this works fine, as expected:
C:\Program Files\WindowsPowerShell\Modules\MyTestModule\MyTestModule.psm1
I am actually surprised anyone has gotten this to work for PS 4.0 - even using the PowerShellGallery. Unless using the PowerShellGallery is a smart install an knows not to use sub-folders with PS 4 machines...
NK
Problem solved. If you use PowerShellGallery to install PowerCLI on a PS 4 machine, it does not create the middle versioning folder:
C:\Program Files\WindowsPowerShell\Modules\VMware.PowerCLI\6.5.1.5377412
Instead it puts the module files right under the module folder:
C:\Program Files\WindowsPowerShell\Modules\VMware.PowerCLI
So the trick is to use a PS 4 machine to download from PowerShellGallery to create the offline files to be used with other PS4 machines (or manually remove the version folder from the PS 5.x downloads before copying to PS 4 machines).
NK
NK, can you post the output of the following?
Get-PackageProvider
Get-PackageProvider -ListAvailable
Get-Module -ListAvailable PowerShellGet,PackageManagement
Get-Module
If there is a problem with installation from the gallery, I'd like to report it back to the Powershell team.
Hello,
I think the gallery is working fine. My problem is that I was using a PS 5 client to download the modules that I was trying to deploy to PS 4 machines. PS 4 does not support the use of different versions of a modules...and the PS 5 version PowerCLI modules included a version sub-folder level in the directory structure that PS 4 machines were choking on.
Thanks
NK
How would you use a PS4 machine to download from the PowerShell Gallery when PS4/WMF4 doesn't support those cmdlets? (Note: Installing PSGet doesn't help with installing modules from the PowerShell Gallery, it seems).
I have solved the problem by removing the version folder from the 16 different PowerCLI module folders but this is a very awkward setup to maintain/update.
Sorry for the late reply. I don't get email notifications for responses to my posts for some reason...
What you need to do is install the PowerShell PackageManagement MSI on your PS 4 machine (PackageManagement_x64.msi). Looks like they still call it "Preview", but I think it is production ready now:
Download PackageManagement PowerShell Modules Preview from Official Microsoft Download Center
NK