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

Can't run within a Job due to version check #12

Open
randallt opened this issue Aug 19, 2024 · 2 comments
Open

Can't run within a Job due to version check #12

randallt opened this issue Aug 19, 2024 · 2 comments

Comments

@randallt
Copy link

I'm trying to run this as part of a job (just locally for now, but eventually remotely), but the minimum version check is failing.

Importing the module like this:

Import-Module FSWatcherEngineEvent

as part of the job fails with this message:

The current Windows PowerShell host is: 'ServerRemoteHost' (version 1.0.0.0). The module 'C:\Users\...\Documents\WindowsPowerShell\Modules\FSWatcherEngineEvent\1.5.0\FSWatcherEngineEvent.psd1' requires a minimum Windows PowerShell host version of '5.1' to run.
    + CategoryInfo          : ResourceUnavailable: (C:\Users\rtheob...ngineEvent.psd1:String) [Import-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_InsufficientPowerShellHostVersion,Microsoft.PowerShell.Commands.ImportModuleCommand
    + PSComputerName        : localhost

If I import the module outside the job, I get a different error:

The 'New-FileSystemWatcher' command was found in the module 'FSWatcherEngineEvent', but the module could not be loaded. For more information, run 'Import-Module FSWatcherEngineEvent'.
    + CategoryInfo          : ObjectNotFound: (New-FileSystemWatcher:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
    + PSComputerName        : localhost

Is this because I only installed the module using scope "CurrentUser"? I'm on a CORP box and don't have admin privileges.
I came across this thread on reddit, but I'm not sure if it is applicable.
https://www.reddit.com/r/PowerShell/comments/s1fcvc/startjob_ps_version_inconsistency/

@wgross
Copy link
Owner

wgross commented Aug 22, 2024

Hi @randallt,
sorry for the late response, I was AFK for some days.

About the loading outside of the job: The module was found but couldn't be loaded. Please try to load the module using Import-Module FSWatcherEngineEvent -Verbose. This should give us more details why the module wasn't loading. If this doesn't work a job can't do it either.

About the version check in the remote host: I don't have an env currently to try this out. What you could try is to remove the version requirement in the module manifest FSWatcherEngineEvent.psd1': Comment the line PowershellHostVersion="5.1" out by adding # at the beginning or simply remove the line and try again. Maybe this helps with the remote host.

@randallt
Copy link
Author

Sorry for not being clear. With regards to:

If I import the module outside the job, I get a different error

The import outside the job is successful, but trying to use it inside the job is where the error occurs.

To reiterate, I was not using a second/remote host here--just trying to use a PowerShell Job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants