Download file to update profile.ps1

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 5
Joined: Fri Aug 19, 2016 7:19 am
Location: Plymouth \ Devon \ UK

Download file to update profile.ps1

Post by mdlister » Thu Mar 30, 2017 5:37 am


I'm looking for some inspiration how best to achieve my goal if it is possible. I have created a module and within it assigned a version number, during the start of the module it does an Invoke-WebRequest and gets the content of the file which is also the latest version. If the numbers match then its the latest version. If they don't then the user needs to download the latest version and overwrite the file.

I was wondering what would be the best way to achieve this? DSC? or call another script to download the file? I'm more than happy to write something I just need to know what path I should take?

.: Lister :.

User avatar
Posts: 13470
Joined: Tue May 22, 2007 9:57 am

Re: Download file to update profile.ps1

Post by jvierra » Thu Mar 30, 2017 10:54 am

Place the module on a network share and just copy the new version over the old version when necessary. The users will always have the latest copy.

No need for a script. Just add a copy command to your project that is executed each time you deploy the project or deploy directly to the module share. You will need to sign the module. Modules should always be signed.

User avatar
Posts: 55
Joined: Mon Jul 22, 2013 7:32 am

Re: Download file to update profile.ps1

Post by OldLost » Thu Mar 30, 2017 12:44 pm

Deploy it as a package to an internal nuget repo!
Trust me, it's easier than it sounds.
Use the Register-PSRepository, Publish-Module, Install-Module, & Update Module cmdlets.
Register-PSRepository -Name "Internal" -SourceLocation "\\fileserver\modules" -PublishLocation "\\fileserver\modules" -InstallationPolicy Trusted