Hello, I just realized Iām having an issue when running this as a scheduled task in Windows. It looks like it runs perfectly when running from the command line. I used the same command to run as a task.
powershell -file c:\script\PlexBackup.ps1 -Type 7zip -BackupRootDir D:\Files\PlexBackups
It created the folder structure, and I assumed it worked. I then noticed my backup folders were only about 5 KB instead of 1+ GB. The 0 folder has a 2 KB Plex.7z file and the reg export worked. The other directories are empty.
C:\Users\<name>\AppData\Local\Temp
is full of large files named PlexBackup-ā¦-.7z (I can show the specifics if needed)
So, run from a cmd prompt works, running from a scheduled task as the same user with elevated rights fails. I tried adding these 2 switches to get more info
-Log -Errorlog
It failed in the same way, and left the .7z files in the temp folder.
PlexBackup v1.5.3 (c) 2019 Alek Davis
Script started at:
04/24/2019 12:39:05
Operation mode:
BACKUP
Backup type:
7ZIP
Log file:
D:\Files\PlexBackups\20190424123905\Backup.log
Error log file:
D:\Files\PlexBackups\20190424123905\Backup.err.log
Plex Media Server version (CURRENT):
1.15.3.876
Stopping Plex service(s):
PlexService
Plex Update Service
Backup will be saved in:
D:\Files\PlexBackups\20190424123905
Deleting old backup folder(s):
20190424103442
20190424102859
20190424102313
20190424101751
Creating task-specific subfolder(s) in:
D:\Files\PlexBackups\20190424123905
Backing up special subfolders.
Moving folder:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
to:
D:\Files\PlexBackups\20190424123905\3\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
at:
2019/04/24 12:39:06.178
Completed at:
2019/04/24 12:39:06.197
Backing up Plex app data files from:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server
to:
D:\Files\PlexBackups\20190424123905\0\Plex.7z
at:
2019/04/24 12:39:06.213
Completed at:
2019/04/24 12:39:06.287
Backing up Plex app data folders from:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server
to:
D:\Files\PlexBackups\20190424123905\1
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Cache
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-e8f3c1c0-7b25-46a6-b296-4f8d35832dc9.7z
at:
2019/04/24 12:39:06.325
Completed at:
2019/04/24 12:40:16.495
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-e8f3c1c0-7b25-46a6-b296-4f8d35832dc9.7z
to:
D:\Files\PlexBackups\20190424123905\1\Cache.7z
at:
2019/04/24 12:40:16.503
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Codecs
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-41d6c000-b133-4d4a-815b-75860d169c03.7z
at:
2019/04/24 12:40:18.892
Completed at:
2019/04/24 12:40:19.436
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-41d6c000-b133-4d4a-815b-75860d169c03.7z
to:
D:\Files\PlexBackups\20190424123905\1\Codecs.7z
at:
2019/04/24 12:40:19.443
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Default
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-b44d69bb-dbfc-43b2-8acf-c4c50d56ad30.7z
at:
2019/04/24 12:40:19.472
Completed at:
2019/04/24 12:40:25.550
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-b44d69bb-dbfc-43b2-8acf-c4c50d56ad30.7z
to:
D:\Files\PlexBackups\20190424123905\1\Default.7z
at:
2019/04/24 12:40:25.558
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Media
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-03af16c0-dcef-4919-a3c1-b992ffd423df.7z
at:
2019/04/24 12:40:25.590
Completed at:
2019/04/24 12:41:19.871
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-03af16c0-dcef-4919-a3c1-b992ffd423df.7z
to:
D:\Files\PlexBackups\20190424123905\1\Media.7z
at:
2019/04/24 12:41:19.879
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Metadata
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-2b9d5e65-6c2e-483a-a8f3-29db47bd923f.7z
at:
2019/04/24 12:41:19.928
Completed at:
2019/04/24 12:42:04.735
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-2b9d5e65-6c2e-483a-a8f3-29db47bd923f.7z
to:
D:\Files\PlexBackups\20190424123905\1\Metadata.7z
at:
2019/04/24 12:42:04.743
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Plug-in Support
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-320480c5-bc2f-4bd7-bc92-fdeb84aec93e.7z
at:
2019/04/24 12:42:04.784
Completed at:
2019/04/24 12:42:21.871
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-320480c5-bc2f-4bd7-bc92-fdeb84aec93e.7z
to:
D:\Files\PlexBackups\20190424123905\1\Plug-in Support.7z
at:
2019/04/24 12:42:21.883
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Plug-ins
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-392a71cc-8736-42a1-a600-e35bb61c88be.7z
at:
2019/04/24 12:42:21.924
Completed at:
2019/04/24 12:42:22.753
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-392a71cc-8736-42a1-a600-e35bb61c88be.7z
to:
D:\Files\PlexBackups\20190424123905\1\Plug-ins.7z
at:
2019/04/24 12:42:22.761
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Archiving:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Scanners
to temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-2aa5497e-90fc-447a-83aa-119a84c7c754.7z
at:
2019/04/24 12:42:22.794
Completed at:
2019/04/24 12:42:22.825
Copying temp file:
C:\Users\MATTHE~1\AppData\Local\Temp\PlexBackup-2aa5497e-90fc-447a-83aa-119a84c7c754.7z
to:
D:\Files\PlexBackups\20190424123905\1\Scanners.7z
at:
2019/04/24 12:42:22.832
Start-BitsTransfer : The operation being requested was not performed because the user has not
logged on to the network. The specified service does not exist. (Exception from HRESULT:
0x800704DD)
At C:\script\PlexBackup.ps1:2488 char:17
+ ... Start-BitsTransfer -Source $tempZipFilePath -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundInte
lligentTransfer.Management.NewBitsTransferCommand
Backing up registry key:
HKCU\Software\Plex, Inc.\Plex Media Server
to:
D:\Files\PlexBackups\20190424123905\2\Plex.reg
Restoring special subfolders.
Copying folder:
D:\Files\PlexBackups\20190424123905\3\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
to:
C:\Users\Matthew <name>\AppData\Local\Plex Media Server\Plug-in Support\Data\com.plexapp.system\DataItems\Deactivated
at:
2019/04/24 12:42:22.909
Completed at:
2019/04/24 12:42:22.927
Starting Plex service(s):
PlexService
Plex Update Service
Script ended at:
2019/04/24 12:42:24.336
Script ran for (hr:min:sec.msec):
00:03:19.241
Script returned:
SUCCESS
Done.
Any ideas? Some sort of environment not working when it is a task maybe?
Seems like it may be this issue:
https://serverfault.com/questions/900689/how-to-properly-run-powershell-scripts-containing-bits-operations-from-task-sche
Update: I fixed my own issue. Iāll leave this here in case anyone else finds this. I had to enable "Run only when user is logged on" in the scheduled task as mentioned in the link above. I didnāt realize that made a difference, since the user is logged in anyway. With that option enabled, I actually saw the powershell script run on the console, and everything worked as expected.