Download file to update profile.ps1

Ask your 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.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
mdlister
Posts: 5
Last visit: Fri Jun 30, 2023 7:29 am

Download file to update profile.ps1

Post by mdlister »

Afternoon,

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?

Mike
.: Lister :.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Download file to update profile.ps1

Post by jvierra »

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
OldLost
Posts: 55
Last visit: Wed Feb 21, 2018 8:00 am

Re: Download file to update profile.ps1

Post by OldLost »

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
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked