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

Only receiving the error "Error processing dependencies. You cannot call a method on a null-valued expression." #79

Closed
ktimb opened this issue Aug 14, 2023 · 6 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@ktimb
Copy link

ktimb commented Aug 14, 2023

I am only receiving the message "Error processing dependencies. You cannot call a method on a null-valued expression."

I've installed the latest NuGet, ScriptVersion, ConfigFile, StreamLogging, and Single Instance.

I'm using Powershell 7.3.6 running as Administrator.

Plex Media Server is version 1.32.6.7371-b6a09ad81 and is verified to be running.

After navigating to the folder containing PlexBackup (C:Windows\System32\PlexBackup), I run the command ".\PlexBackup.ps1"

I've tried using no config file, a config file with fully default values, and an edited config file.

I've run ".\PlexBackup.ps1 - Test".

I've used "Get-ChildItem" to verify that "PlexBackup.ps1" exists in the current directory.

I've tried downloading PlexBackup to another directory (directly to C:\PlexBackup) and running it there.

No matter what I only get the above message and no log files or other messages are created.

Can you offer any advice?

@alekdavis alekdavis self-assigned this Aug 14, 2023
@alekdavis
Copy link
Owner

Since you are are getting an error from PlexBackup.ps1, there is no question whether it exists in the current directory. The error comes from this block:

    try {
        $psVersion = GetPowerShellversion
        Write-Verbose "Microsoft PowerShell v$psVersion"

        # Add custom folder(s) to the module path.
        SetModulePath

        # Load module dependencies.
        LoadModules $MODULES
    }
    catch {
        throw (New-Object System.Exception( `
            "Error processing dependencies.", $_.Exception))
    }

I would try running it with the -Debug -Verbose flags to see if there is mor info. The output should tell you in what method the error occurs. If this does not help, I would run it in the debugger to see what is going on.

@ktimb
Copy link
Author

ktimb commented Aug 14, 2023

That gets me the following.

PS C:\PlexBackup-master> .\PlexBackup.ps1 -Debug -Verbose -Inactive
VERBOSE: Entered Main.
VERBOSE: Entered GetPowerShellVersion.
VERBOSE: Exiting GetScriptVersion.
Error processing dependencies. You cannot call a method on a null-valued expression.
VERBOSE: SingleInstance module is not loaded.
VERBOSE: Entered StopLogging.
VERBOSE: Logging has not started, so nothing to uninitialize.
VERBOSE: Exiting StopLogging.
VERBOSE: Exiting Main.

So I guess something is wrong with ScriptVersion?

@ktimb ktimb closed this as completed Aug 14, 2023
@ktimb ktimb reopened this Aug 14, 2023
@alekdavis
Copy link
Owner

What do you get if you enter this in PowerShell prompt:

$PSVersionTable.PSVersion

@ktimb
Copy link
Author

ktimb commented Aug 14, 2023

PS C:\PlexBackup-master> $PSVersionTable.PSVersion

Major Minor Patch PreReleaseLabel BuildLabel


7 3 6

Sorry, I'm not sure how to get that to format correctly.
Major 7
Minor 3
Patch 6

@ktimb ktimb closed this as completed Aug 14, 2023
@ktimb ktimb reopened this Aug 14, 2023
@alekdavis
Copy link
Owner

Ah. It looks like they changed it in PowerShell 7. In PowerShell 5, I get

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      22621  1778

So, for now, I would try running it from an earlier version of PowerShell because I have not tested it in PowerShell 7 (I think PowerShell 7 has its own environment, but it does not remove older versions). I will try to port it to PowerShell 7, but can't promise when. Let me know if it fixes the issue.

@ktimb
Copy link
Author

ktimb commented Aug 14, 2023

That's solved it. Thanks so much for your help and for the script!

@ktimb ktimb closed this as completed Aug 14, 2023
@alekdavis alekdavis added the help wanted Extra attention is needed label Aug 14, 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

2 participants