Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapped network drive not available after script restarts Plex #26

Closed
yangqi opened this issue Feb 22, 2020 · 15 comments
Closed

Mapped network drive not available after script restarts Plex #26

yangqi opened this issue Feb 22, 2020 · 15 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@yangqi
Copy link

yangqi commented Feb 22, 2020

All my libraries are saved on mapped network drives on NAS. Every time the script finishes, all my libraries become unavailable, and I could not see those drives from Plex. Have to restart Plex manually for them to work.

@alekdavis
Copy link
Owner

Please check #4

@yangqi
Copy link
Author

yangqi commented Feb 24, 2020

Thank you, read through that one. And I have tested running the command manually.

Start-Process <PMS> -LoadUserProfile

Run this in Powershell with Administrator, got the same issue as the script.
Run this in Powershell without Administrator, everything seems fine.

Both cases, the PMS shows running under current user in task manager, the only difference is the UAC Virtualization column, first one said "Not allowed", second says "Disabled". Not sure if this is related or not though.

@alekdavis
Copy link
Owner

The problem is that the script needs to run as Administrator; otherwise, it will not have permissions to stop and start services and processes. If you have any ideas, throw them at me and I'll give them a try.

@alekdavis
Copy link
Owner

Okay, give this a try. Change line 1808 from:

Start-Process $plexServerExePath -LoadUserProfile

to

runas /trustlevel:0x20000 "$plexServerExePath"

See if this helps.

@alekdavis
Copy link
Owner

@yangqi Any luck?

@Doughboy68
Copy link

Hi first of all thanks for the script.

I have the same problem with network shares and came here. I created a test Powershell with various ways to run the Plex Media Server.exe and none of these work (I comment out all of them here but I would uncomment to try different approaches):

The user/pass for my server is plex\plex
`$username = 'plex'
$password = 'plex'

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword
#Start-Process -FilePath "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe" -Credential $credential
#runas /trustlevel:0x20000 "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe"
#Start-Process -FilePath "C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Server.exe" -LoadUserProfile -Credential $credential
`
The only way I can get it to work as in recognize paths/play video is end the task from tool tray and run it from the Windows Start Menu then it recognizes the paths and plays correctly.

This has me stumped, but it believe it has to do with Administrator permissions for network folders, however I do verify in task manager that the services are running under Plex user correctly so ???

Can you add a reboot option... my Windows Plex server is set to auto login so this would be a workaround... I suppose I can just add this in code myself too for now - Restart-Computer
Would be nice to learn why PowerShell and Plex behaves this way.

@alekdavis
Copy link
Owner

@Doughboy68: Have you tried my suggestion for @yangqi above? I have been testing it daily for the last week, and it seems to be working for me (I am also using an option to log off all currently logged users). It could be a coincidence, though, since this particular problem comes and goes. Also, it has nothing to do with Plex per se, and it's not an issue of PowerShell, I think. It does not happen when you run the script interactively and only occurs when you run it as a scheduled task. So it looks like some bug in Windows Scheduled Tasks app. Anyway, give my suggestion a try and let me know.

@alekdavis alekdavis self-assigned this May 22, 2020
@alekdavis
Copy link
Owner

I added a reboot option so this is the workaround I am using for now. If anyone figures out why scheduled tasks mess up remote share connection, please let me know.

@K-Bong
Copy link

K-Bong commented Nov 4, 2021

Hi Alek,

Have recently found your script and after some trouble figuring it out (total noob). I've finally got it work and it's awesome!

I have however run into this old issue though #26. I was just wondering if you figured out anything additional since Aug 2020?

I've changed line 2331/2332, and tried both of these below as you suggested and still get the issue unfortunately.

Start-Process $plexServerPath -LoadUserProfile

runas /trustlevel:0x20000 "$plexServerPath"

Was wondering if you've come up with anything since then? Just a bit iffy to run it as a scheduled task at the moment as I'd have to reboot the application everytime.

@alekdavis
Copy link
Owner

Hi K-Bong. No, haven't figured it out. I suspect it's an issue with Windows Scheduled tasks or something related to the tasking subsystem (since it only happens when the script runs as a scheduled task). I just have mine configured to reboot with autologin.

@K-Bong
Copy link

K-Bong commented Nov 4, 2021

Thanks for responding. I do get the issue when running the script directly from PowerShell, and as a scheduled task by the way.

But it's no biggie, I might just try what you mentioned or just run the script manully, cheers!

@alekdavis
Copy link
Owner

Oh, in my observation, it was always a Scheduled Tasks issue. Are you saying that even when you run it manually in PowerShell, you get the same problem? That would be even more weird.

@K-Bong
Copy link

K-Bong commented Nov 4, 2021

Yep. I wanted to make sure the script worked first before running the scheduled task. I would see the behaviour throughout the whole thing, whether I ran it from powershell or through task scheduler.

@alekdavis
Copy link
Owner

That's bizarre. I am wondering if when you run it from PowerShell, the profile by default gets connected to a share with no permissions. I wish I know how to address this one.

@K-Bong
Copy link

K-Bong commented Nov 4, 2021

Yeah. Otherwise it works well, so appreciated. Sure you'll keep us updated if you do figure something out.

@alekdavis alekdavis added the help wanted Extra attention is needed label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants