Powershell command not recognized

Sonarr version (exact version): 3.0.4.993
OS: Windows 10
Description of issue:

After the Growl support was removed I’m desperately trying to find a solution for local desktop notifications again. I’m trying to get BurntToast working but I’m immediately running into a wall. I’m getting the follow error in Sonarr trying to run my test .ps1:

|Error|powershell.exe|New-BurntToastNotification : The term 'New-BurntToastNotification' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The default Powershell version on my system is 5.1.19041.546 and the command as well as the test script has no issues when called manually. I have installed BurntToast for all users and for both v5 and v7. I can’t figure out why the module isn’t available when called from Sonarr. Is it not using the default system powershell.exe?

Any ideas?

Are you running Sonarr as a Windows service (check Mode in System: Info), if so that could be the difference (running as a different user).

Sonarr calls powershell like so: powershell.exe", $"-ExecutionPolicy Bypass -NoProfile -File {filename}, not sure if that’ll affect things.

It is indeed running as a service which is why I thought installing the module for all users would help, but clearly not. Any idea as how to install the module so that Sonarr can use it? I realize this is related to Windows rather than Sonarr though.

I’m not sure. Does it work if you don’t run Sonarr as a Windows service?

add an Import-Module name-of-burnt-toast-module at the top of your powershell script so that it gets loaded.

the noprofile option being used to call powershell by sonarr means only the default modules are loaded and nothing else.

you can test your script manually by starting powershell with the noprofile option yourself, then getting it to work in there

No I get the same error when running Sonarr in tray mode.

Ah, thank you, some progress and clues. I still get the same error when only using Import-Module BurntToast but when including the full path I get an Access Denied error instead. Running Sonarr in tray mode instead of service mode and including the full path works though.

The module is available in both C:\Users\user\Documents\WindowsPowerShell\Modules and C:\Program Files\WindowsPowerShell\Modules, but not C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules. So I’m guessing the Sonarr powershell call only checks the system32 module folder? Though it isn’t recommended to install modules there it seems.

Question is if it’s possible to give the correct permissions to Sonarr running in service mode I guess.

the issue is the user that the service is running under is very limited - deliberately so and for good reasons

You need to change the user to another with more privileges so your PS script can work
or dont use sonarr as a service and get it to start with a windows startup shortcut

I see, that would explain it. It does work if I run the service logged on as an admin account and specify the Import-Module path. Kind of defeats the purpose of having Sonarr running as a service I guess, so I think I’ll go the tray mode route. Thank you.

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