Using PowerShell custom script on Win7

Sonarr version (exact version): 2.0.0.4146
Mono version (if Sonarr is not running on Windows): n/a
OS: Windows 7 Ultimate (32-bit)
((Debug logs)) (posted to hastebin or similar):
Description of issue:

I am attempting to execute a PowerShell script as a Custom Script notification. As PS1 script files are not directly executable, my Path is: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe and my Arguments are: -NoProfile -ExecutionPolicy Bypass -File C:\Resources\OnSonarrEvent.ps1.

When executed from a command prompt, this combination executes properly. When triggered from within Sonarr, the powershell process never ends, causing the notification to “hang” as it is stuck on process.WaitForExit(). Any ideas why the process never exits when Sonarr executes it? Here is a snipped from the debug log. When I manually kill the process, after about 60 seconds of waiting, you’ll see the entry “Executed external script…”. Thanks in advance.

16-5-23 10:15:44.3|Info|DownloadService|Report sent to uTorrent. Tiny.House.Nation.S04E09.600.Sq.Ft.Tiny.Victorian.720p.WEB-DL.AAC2.0.H264-BTN[rartv]
16-5-23 10:15:44.3|Debug|NotificationService|No tags set for this notification.
16-5-23 10:15:44.3|Debug|CustomScript|Executing external script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
16-5-23 10:15:44.4|Debug|powershell.exe|Starting C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Resources\OnSonarrEvent.ps1
16-5-23 10:15:52.4|Debug|Api|[GET] /api/health: 200.OK (0 ms)
16-5-23 10:15:52.4|Debug|Api|[GET] /api/health: 200.OK (0 ms)
16-5-23 10:15:52.4|Debug|Api|[GET] /api/diskspace: 200.OK (16 ms)
16-5-23 10:15:52.4|Debug|Api|[GET] /api/diskspace: 200.OK (12 ms)
16-5-23 10:15:53.5|Debug|SabnzbdProxy|Url: http://localhost:8085/api?mode=queue&start=0&limit=0&apikey=(removed)&output=json
16-5-23 10:15:54.5|Debug|SabnzbdProxy|Url: http://localhost:8085/api?mode=history&start=0&limit=30&category=tv&apikey=(removed)&output=json
16-5-23 10:15:54.5|Debug|Parser|Parsing string 'Fear.the.Walking.Dead.S02E07.720p.HDTV.x264-AVS[rarbg]'
16-5-23 10:15:54.5|Debug|Parser|Episode Parsed. Fear the Walking Dead - S02E07
16-5-23 10:15:54.5|Debug|Parser|Language parsed: English
16-5-23 10:15:54.5|Debug|NzbDrone.Core.Parser.QualityParser|Trying to parse quality for Fear.the.Walking.Dead.S02E07.720p.HDTV.x264-AVS[rarbg]
16-5-23 10:15:54.5|Debug|Parser|Quality parsed: HDTV-720p v1
16-5-23 10:15:54.5|Debug|Parser|Release Group parsed: AVS
16-5-23 10:15:54.5|Debug|Parser|Parsing string 'Tiny.House.Nation.S04E09.600.Sq.Ft.Tiny.Victorian.720p.WEB-DL.AAC2.0.H264-BTN[rartv]'
16-5-23 10:15:54.5|Debug|Parser|Episode Parsed. Tiny House Nation - S04E09
16-5-23 10:15:54.5|Debug|Parser|Language parsed: English
16-5-23 10:15:54.5|Debug|NzbDrone.Core.Parser.QualityParser|Trying to parse quality for Tiny.House.Nation.S04E09.600.Sq.Ft.Tiny.Victorian.720p.WEB-DL.AAC2.0.H264-BTN[rartv]
16-5-23 10:15:54.5|Debug|Parser|Quality parsed: WEBDL-720p v1
16-5-23 10:15:54.5|Debug|Parser|Release Group parsed: BTN
16-5-23 10:15:54.5|Debug|Parser|Parsing string 'Naked.and.Afraid.S05E10.Bad.Blood.720p.HDTV.x264-DHD[rarbg]'
16-5-23 10:15:54.5|Debug|Parser|Episode Parsed. Naked and Afraid - S05E10
16-5-23 10:15:54.5|Debug|Parser|Language parsed: English
16-5-23 10:15:54.5|Debug|NzbDrone.Core.Parser.QualityParser|Trying to parse quality for Naked.and.Afraid.S05E10.Bad.Blood.720p.HDTV.x264-DHD[rarbg]
16-5-23 10:15:54.6|Debug|Parser|Quality parsed: HDTV-720p v1
16-5-23 10:15:54.6|Debug|Parser|Release Group parsed: DHD
16-5-23 10:15:54.6|Debug|Api|[GET] /api/queue?sort_by=timeleft&order=asc: 200.OK (0 ms)
16-5-23 10:15:56.3|Debug|Api|[GET] /api/log?page=1&pageSize=50&sortKey=time&sortDir=desc: 200.OK (0 ms)
16-5-23 10:15:56.3|Debug|Api|[GET] /api/log?page=1&pageSize=50&sortKey=time&sortDir=desc: 200.OK (7 ms)
16-5-23 10:16:10.4|Debug|Api|[GET] /api/log/file: 200.OK (15 ms)
16-5-23 10:16:10.4|Debug|Api|[GET] /api/log/file/sonarr.debug.txt: 200.OK (1 ms)
16-5-23 10:16:12.2|Debug|Api|[GET] /api/log/file/sonarr.debug.txt: 200.OK (0 ms)
16-5-23 10:16:50.3|Debug|CustomScript|Executed external script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe - Status: 1
16-5-23 10:16:50.3|Debug|CustomScript|Script Output:

16-5-23 10:16:50.3|Debug|Api|[POST] /api/release: 200.OK (65949 ms)
16-5-23 10:16:55.3|Debug|SabnzbdProxy|Url: http://localhost:8085/api?mode=queue&start=0&limit=0&apikey=(removed)&output=json
16-5-23 10:16:55.3|Debug|SabnzbdProxy|Url: http://localhost:8085/api?mode=history&start=0&limit=30&category=tv&apikey=(removed)&output=json

I’d suggest logging output from the powershell script to a file, etc. so you can see if the script itself is actually causing the stopping. Calling powershell via non-cmd will potentially act slightly different.

FWIW, using PowerShell was causing other unwanted side-effects elsewhere in my setup (e.g., the PowerShell console window that always pops up). So I just re-wrote everything as a C# app and all appears well now.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.