So when writing a new PowerShell Module, you should consider how people are going to download it. Commonly these PowerShell modules have been tucked away behind vendor support websites that require logon, and while this method is usable, it doesn’t lend itself to supporting automation.
This is the brave new world, and in this new world, we expect servers to configure themselves, and if your like me you sure as heck don’t want to embed your username and password to a vendor site in your scripts especially if that site is for Infosight.hpe.com. 🙂
Of course the answer to this question is PS Gallery, which is a website similar to GitHub that hosts PowerShell Modules. Below I outline the steps to allow a Windows Server to obtain modules directly from the PS Gallery.
The first step is to download the per-requisites such as NuGet and PowerShellGet; Make sure to use an Administrator PowerShell Window for the following steps.
PS:> Install-PackageProvider -name NuGet -force
Name Version Source Summary
---- ------- ------ -------
nuget 22.214.171.124 https://onege… NuGet provider for the...
Additionally you will need to download a newer version of the PowerShellGet module;
PS:> update-module -name powershellget -force
And by default Microsoft does not trust even its own sites, you must tell your server to allow itself to download from the PS Gallery.
PS:> Set-PSRepository -name PSGallery -InstallationPolicy Trusted
Once these per-requisites have been done, you can download any of the Modules, but we don’t want ANY old module, we want the HPE Nimble Storage Module. The easiest way to find the module is to use the find command as follows; Note that I am lazy, so I use ‘*’ wildcards when I can.
PS C:\Windows\system32> Find-Module hpe*
Of course we only need one module, and as long as our query only returns a single module, we can pipe that directly to the Install-Module commands.
Special note here, you must explicitly accept the license or you will not be able to download the module.
PS:> Find-Module HPENi* | Install-Module -AcceptLicense
PS:> Import-Module HPENimblePowerShellToolkit