PS to download latest microsip version
-
I wanted a way to keep microSIP updated to the latest version automatically.
I wrote this script and have a couple of questions.
# Create a WebClient object $webClient = New-Object System.Net.WebClient # URL for the MicroSIP download page $url = "https://microsip.org/downloads" # Download the HTML content of the MicroSIP download page $html = $webClient.DownloadString($url) #write-output $html # Use regular expression to extract the download link for the most recent version of MicroSIP Zip $newversion = Select-String "(MicroSIP-.......zip)" -InputObject $html # create full download url $downloadurl = "https://microsip.org/download/" + $newversion.matches.value #Write-Output $downloadurl # check if destination folder exists $folderPath = $env:HOMEDRIVE + $env:HOMEPATH + "\appdata\local\temp\microsip" if (!(Test-Path -Path $folderPath -PathType Container)) { New-Item -ItemType Directory -Path $folderPath } # set download destination path and name $dest = $env:HOMEDRIVE + $env:HOMEPATH + "\appdata\local\temp\microsip\microsip.zip" #Write-Output $dest # download file from URL Invoke-WebRequest -Uri $downloadurl -OutFile $dest # set user's microsip path $destuserfolder = $env:HOMEDRIVE + $env:HOMEPATH + "\appdata\MicroSIP" # extract zip to current user's microsip file Expand-Archive -LiteralPath $dest -DestinationPath $destuserfolder -Force # set user's microsip contact path and name $contact = $env:HOMEDRIVE + $env:HOMEPATH + "\appdata\MicroSIP\Contacts.xml" # set user's document directory path $mydocuments = [environment]::getfolderpath("mydocuments") # backup contacts to user's documents Copy-Item -Path $contact -Destination $mydocuments -Force
This does the job I want just fine - finds the first entry of MicroSIP.........zip then downloads it, extracts it to the user's microsip folder, then backs up their contacts to their documents folder.
The problems I forsee:
-
If microsip changes their page layout, it's possible the link won't be the first zip on the page
-
If microsip changes the length of their version numbers, the script will break
Any thoughts on how I can fix these?
-
-
@Dashrender said in PS to download latest microsip version:
Any thoughts on how I can fix these?
Chocolatey
-
@Obsolesce said in PS to download latest microsip version:
@Dashrender said in PS to download latest microsip version:
Any thoughts on how I can fix these?
Chocolatey
I have to dig into that again - there was a reason I didn't go that route - something didn't work as desired...can't recall what.
-
I just installed it on a test machine with chocolatey - it installed it into the local admin profile - so any normal non admin user can't use it.
-
@Dashrender said in PS to download latest microsip version:
I just installed it on a test machine with chocolatey - it installed it into the local admin profile - so any normal non admin user can't use it.
You can use chocolatey to get the current version and download url. I don't install apps from chocolatey corporately, but I use it to obtain current versions of software and/or download links.
-
@Obsolesce said in PS to download latest microsip version:
@Dashrender said in PS to download latest microsip version:
Any thoughts on how I can fix these?
Chocolatey
That's what we use.
-
@Dashrender said in PS to download latest microsip version:
I just installed it on a test machine with chocolatey - it installed it into the local admin profile - so any normal non admin user can't use it.
You can run chocolatey without admin rights just fine.
It warns you, but that is because most software is designed to be installed with admin rights in the windows world.
It seems that Microsip does not require that, so run chocolatey as the user itself.
-
@JaredBusch said in PS to download latest microsip version:
@Dashrender said in PS to download latest microsip version:
I just installed it on a test machine with chocolatey - it installed it into the local admin profile - so any normal non admin user can't use it.
You can run chocolatey without admin rights just fine.
It warns you, but that is because most software is designed to be installed with admin rights in the windows world.
It seems that Microsip does not require that, so run chocolatey as the user itself.
interesting - something else to test then.
will the choco update scripts catch both admin and non admin installed items?
-
@Dashrender said in PS to download latest microsip version:
@JaredBusch said in PS to download latest microsip version:
@Dashrender said in PS to download latest microsip version:
I just installed it on a test machine with chocolatey - it installed it into the local admin profile - so any normal non admin user can't use it.
You can run chocolatey without admin rights just fine.
It warns you, but that is because most software is designed to be installed with admin rights in the windows world.
It seems that Microsip does not require that, so run chocolatey as the user itself.
interesting - something else to test then.
will the choco update scripts catch both admin and non admin installed items?
It depends on whether or not it was installed with elevated privileges and whether or not a given software is installed to a location that requires elevated privileges to modify.