One thing that seems to interest even the most advance PowerShell user is the concept of having an Internal Repository of scripts for their team to share and have version control over. I will say for a Sys Admin this has been a very challenging experience in figuring out what to use and I want to share what I have learned. Starting in Windows PowerShell 5.0 Microsoft includes the PowerShellGet module (Powershell Gallery for more info) which allows users to download new modules and scripts from the online PowerShell Gallery. These modules also allow users to create their own internal gallery and store custom scripts or modules within it. In future post I will probably cover more info on package management.
Setting up the repo
Since Windows includes the NuGet provider it makes sense to set up a NuGet Server. Most results from online searches require Visual Studio to do a NuGet.server install. I decided I didn’t want to go this route and found a few solutions available online and I ended up using an open source demo solution on github called PSPrivateGallery.
Getting started once the repo is online
After I got PSPrivateGallery installed and configured I decided to give it a try.
I updated to the newest version of PowerShellGet, at the time I wrote this version 22.214.171.124 was available in the PowerShell Gallery.
I had issues with the update-scriptfileinfo cmdlet until I updated it
In PowerShell Add the Repository to the list of repo’s
Now create a new script using the New-ScriptFileInfo cmdlet. This sets the metadata for a new script.
Add cmdlets, Save and close the file
Validate the script by running:
Publish the script.
Check and see if the script was published
Version 1.0 is now published for my team to share. Now lets say I make modifications to that script. Once all the modifications are done I need to update the version number.
Publish the modifications to the repo
Validate the versions
Using the script
Make sure the repository is defined on the machine that needs the script. Using the register-psrepository cmdlet
Create a folder to download the script to and validate it is the current version.
Just like that admins can now publish and version their scripts.
That is all I have for today, thanks for reading and I hope you find this info useful.
Just a quick note, I use this blog as a way to share things I have discovered. Most of the time I’m in a rush to get it out and my grammar and spelling is horrific. I usually proof read after I post and try to fix things as I see them.