Import-Modules offline issues with .NUPKG Files

We recently ran into an issue with importing modules for a PowerShell DSC Script. It was not the normally scenario where you just import the modules via the internet from the PSGallery, as the machines we were working with had no internet access.

First thing we did was to download .NUPKG files of the DSC modules so that we could manually import the modules from a local repository. However we ran into the issue of, when we imported the module it was just not appearing when running the command “get-dscresource”.

After researching online, a lot of people on GitHub were reporting that this was due to a version mismatch between the .nuspec file and .psd1 file.

To see if you have the same issue you can follow the below steps:

  • Rename package from .nupkg to .zip

  • Extract all files from the .ZIP folder and open the extracted folder
  • Open the psd1 file and make a note of the moduleVersion number

  • Now open the nuspec file and check the version number to matches with the PSD1 file

If the versions don’t match you have found your issue! Issues appears that the .nuspec file has truncated the version numbers, reduces version number from to 13.2.0.

  • Update the .nuspec file and rezip the folder
  • Rename the .zip folder back to .nuget

That should do the trick and the import-module should now work from your local repository!

About the author