hatharry 85 Posted November 27, 2015 Share Posted November 27, 2015 (edited) Updates Emby when running as a service. .\EmbyServiceUpdater.ps1 -ApiKey "YOUR_API_KEY" -ServerUrl "http://YOUR_SERVER_URL:PORT" [-InstallTask] [-UninstallTask] [-UpdateScript] Github: https://github.com/hatharry/Emby.ServerUpdater/blob/master/EmbyServiceUpdater.ps1 Note: An Emby api key and url is required, The api key can be created using the dashboard advanced menu, security tab. Edited April 30, 2019 by hatharry 13 Link to comment Share on other sites More sharing options...
Luke 37063 Posted November 27, 2015 Share Posted November 27, 2015 Great stuff here! Link to comment Share on other sites More sharing options...
hatharry 85 Posted December 7, 2015 Author Share Posted December 7, 2015 (edited) [removed] Edited July 31, 2018 by hatharry 2 Link to comment Share on other sites More sharing options...
denethor 90 Posted December 7, 2015 Share Posted December 7, 2015 Wow now I get go back to Dev for "SystemUpdateLevel". It was a pain in the a** since it requires some manual operations while running as a service Link to comment Share on other sites More sharing options...
jordy 284 Posted January 4, 2016 Share Posted January 4, 2016 @@hatharry, Now that Luke has moved the install files to Github, could you re-write this to point to the new location for downloads please. Also a version to update Dev branch would be great. Many Thanks. Link to comment Share on other sites More sharing options...
mediacowboy 438 Posted January 4, 2016 Share Posted January 4, 2016 I don't use this right now but I had an idea come to me. Why not get this merged into the server. Have the option during install to run a a service. Then any time the server gets notified of a server reboot it run the exercise @@hatharry has created. 1 Link to comment Share on other sites More sharing options...
Luke 37063 Posted January 4, 2016 Share Posted January 4, 2016 Why not put it on github? It's nice to see emby-related projects pop up there. Link to comment Share on other sites More sharing options...
jordy 284 Posted January 4, 2016 Share Posted January 4, 2016 @@mediacowboy, I thought the same too. I pretty much thought that seeing as Luke liked or was appreciative of it before, he might be inclined to add it to the server anyway. It seems like a relatively simple piece of code to add afterall. But seeing that this was not the case... Link to comment Share on other sites More sharing options...
hatharry 85 Posted January 4, 2016 Author Share Posted January 4, 2016 Now that it has been running stable for a while now i will add it to github. would be good to see it merged with server. 2 Link to comment Share on other sites More sharing options...
jordy 284 Posted January 4, 2016 Share Posted January 4, 2016 Nice Sent from my HUAWEI MT7-L09 using Tapatalk Link to comment Share on other sites More sharing options...
hatharry 85 Posted January 4, 2016 Author Share Posted January 4, 2016 Git can be found here 1 Link to comment Share on other sites More sharing options...
FrostByte 5049 Posted January 25, 2016 Share Posted January 25, 2016 (edited) Thanks hatharry, didn't realize this was moved. Makes more sense here though. Your version probably works much better, but posting updated PowerShell script files from server support forum in case anyone wanted Script updated with new server locations #Test for admin permissions If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { #"No Administrative rights, it will display a popup window asking user for Admin rights" $arguments = "& '" + $myinvocation.mycommand.definition + "'" Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments break } $ServiceDisplayName = 'Media Browser', 'Emby Server' $ServiceName = 'MediaBrowser', 'Emby' $ProcessName = 'MediaBrowser.ServerApplication' # Installer download path $downloadPath = "$env:USERPROFILE\Downloads" $InstallFolder = 'MediaBrowser-Server', 'Emby-Server' #Find install folder foreach ($string in $InstallFolder) { if (Test-Path -Path $env:USERPROFILE\AppData\Roaming\$string ) {$InstallFolder = $string} } # Stop the emby service "Stopping service" foreach ($string in $ServiceDisplayName) { Stop-Service -DisplayName $string -ErrorAction SilentlyContinue } Stop-Process -Name $ProcessName -ErrorAction SilentlyContinue -Force Wait-Process -Name $ProcessName -ErrorAction SilentlyContinue # Download installer write-host "Downloading installer" $filename = 'setup.exe' $SUL = Select-String $env:USERPROFILE\AppData\Roaming\$InstallFolder\config\System.xml -pattern "SystemUpdateLevel" if ($SUL -match "Release") {$level = "release"} if ($SUL -match "Beta") {$level = "beta"} if ($SUL -match "Dev") {$level = "dev"} $source = "https://github.com/MediaBrowser/Emby.Releases/raw/master/Server/windows/$level/$filename" $destination = "$downloadPath" + "\" + "$fileName" Invoke-WebRequest $source -OutFile $destination # Run installer write-host "Running installer" & $destination | Out-Null "Waiting for emby" $process = get-Process -Name $ProcessName -ErrorAction SilentlyContinue while (!$process) { $process = get-Process -Name $ProcessName -ErrorAction SilentlyContinue } # Kill the emby app that gets started. write-host "Finding emby service" foreach ($string in $ServiceDisplayName) { if (Get-Service -DisplayName $string -ErrorAction SilentlyContinue) { $emby = Get-Service -DisplayName $string -ErrorAction SilentlyContinue } } while (!$emby) { # Check the app is running. Wait until it starts foreach ($string in $ServiceDisplayName) { if (Get-Service -DisplayName $string -ErrorAction SilentlyContinue) { $emby = Get-Service -DisplayName $string -ErrorAction SilentlyContinue } } } #Close emby write-host "Closing emby" Stop-Process -Name $ProcessName -ErrorAction SilentlyContinue -Force Wait-Process -Name $ProcessName -ErrorAction SilentlyContinue # Delete downloaded installer write-host "Deleting installer" Remove-Item $destination #Restart the emby service write-host "Setting service to auto startup" foreach ($string in $ServiceName) { Set-Service -Name $string -StartupType Automatic -ErrorAction SilentlyContinue } #Start service write-host "Starting service" foreach ($string in $ServiceDisplayName) { Start-Service -DisplayName $string -ErrorAction SilentlyContinue } #Complete write-host "Completed emby update" Batch file (needs to be named the same as script file to work) @ECHO OFF PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}" EmbyServerUpdate.zip Edited January 26, 2016 by FrostByte 2 Link to comment Share on other sites More sharing options...
hatharry 85 Posted February 4, 2016 Author Share Posted February 4, 2016 Updated to download from github Link to comment Share on other sites More sharing options...
MSattler 387 Posted February 4, 2016 Share Posted February 4, 2016 Works pretty sweet! Link to comment Share on other sites More sharing options...
hatharry 85 Posted February 4, 2016 Author Share Posted February 4, 2016 Fixed Task Creation Link to comment Share on other sites More sharing options...
Luke 37063 Posted February 4, 2016 Share Posted February 4, 2016 Well done Link to comment Share on other sites More sharing options...
hatharry 85 Posted February 18, 2016 Author Share Posted February 18, 2016 Added check to see if emby is closed before continuing. Removed Mediabrowser from service list. If your computer has both mediabrowser and emby service, running "sc delete mediabrowser" will remove the mediabrowser service Link to comment Share on other sites More sharing options...
hansolo77 11 Posted May 20, 2016 Share Posted May 20, 2016 I'm not familiar with github... How do I download and install this? Is the link in the first post the latest version? Thanks for the work! Link to comment Share on other sites More sharing options...
Koleckai Silvestri 1150 Posted May 20, 2016 Share Posted May 20, 2016 I'm not familiar with github... How do I download and install this? Is the link in the first post the latest version? Thanks for the work! The post from Frostbyte is probably the newest version here. If you download from Github, click on the green "Clone or Download" button. Select Download ZIP. When you unzip it, the script will be on the sub-folder. Double-click it to run. You must have Windows Powershell installed beforehand, though. Link to comment Share on other sites More sharing options...
hansolo77 11 Posted May 20, 2016 Share Posted May 20, 2016 (edited) Thanks. I thought FrostByte's was the latest too, but then there were replies after that with further updates. I just wasn't sure if the link in the first post was the latest then (because it had been updated). I think obviously the one on Github is going to be the latest anyway, so I'll see if I can figure that out. Also, I'm pretty sure I have Powershell installed too, comes with Windows Server. Thanks again! EDIT - Didn't work.. I went with the zip file from the OneDrive instead. The Github link doesn't provide an exe. Like it needs compiled or something. But the zip (also found in the OP) did contain the exe. It ran fine, scheduled the task, and auto installed the update. Does the scheduled task it creates only restart the server when an update is ready to install, or will it restart every time regardless? I think "everytime" would require that -restart flag right? Edited May 20, 2016 by hansolo77 Link to comment Share on other sites More sharing options...
hatharry 85 Posted May 23, 2016 Author Share Posted May 23, 2016 The exe is fully unattended, the powershell script is not. I'll put the executables on github. The server will only restart when it has an update. Emby.ServerUpdater.exe -restart -download will restart server every time and check for update. Thanks. I thought FrostByte's was the latest too, but then there were replies after that with further updates. I just wasn't sure if the link in the first post was the latest then (because it had been updated). I think obviously the one on Github is going to be the latest anyway, so I'll see if I can figure that out. Also, I'm pretty sure I have Powershell installed too, comes with Windows Server. Thanks again! EDIT - Didn't work.. I went with the zip file from the OneDrive instead. The Github link doesn't provide an exe. Like it needs compiled or something. But the zip (also found in the OP) did contain the exe. It ran fine, scheduled the task, and auto installed the update. Does the scheduled task it creates only restart the server when an update is ready to install, or will it restart every time regardless? I think "everytime" would require that -restart flag right? Link to comment Share on other sites More sharing options...
Doonga 17 Posted June 23, 2016 Share Posted June 23, 2016 (edited) Having some issues with this. I'm using the .exe version. After an update, it leaves Emby in a stopped state. If I restart it manually, I get an Emby log that shows that the update needs to apply, then when I restart the service again, it starts up normally. Should I be running the scheduled task as my Emby user or as SYSTEM? Edited June 23, 2016 by Doonga Link to comment Share on other sites More sharing options...
hatharry 85 Posted June 23, 2016 Author Share Posted June 23, 2016 Thanks for letting me know. Should be fixed now. 1 Link to comment Share on other sites More sharing options...
Doonga 17 Posted June 23, 2016 Share Posted June 23, 2016 Closer... Now it restarts and does the update, but then Emby exits again and ends up stopped. So I had to start it again. Seems like it needs 1 more start at the end and we're back in business. Link to comment Share on other sites More sharing options...
hatharry 85 Posted June 24, 2016 Author Share Posted June 24, 2016 It does. You're not waiting long enough. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now