Powershell JEA don't work with file operation

Kirill 26 Reputation points
2023-09-08T07:12:11.84+00:00

Hello!

Try to write a script that will connect to remote computer and perform some tasks.

It use JEA and invoke-command

Example:

Invoke-Command -ComputerName 'ServerName' -ConfigurationName MyJEATask -ScriptBlock {}

Most of commands work fine, except all filesystem commands: test-path, get-childitem, new-item.

When i perform enter-pssession and get-command i could see, that all of them are available.

But when try to perform something with files - get an error.

test-path - always show False

new-item - Cannot find a provider with the name 'FileSystem'.

get-item - Cannot find a provider with the name 'FileSystem'.

get-childitem - Cannot find a provider with the name 'FileSystem'.

Of couse all of them are added to PSRC file without any parameters:

VisibleCmdlets = 'New-Item','Test-Path','Unregister-ScheduledTask','get-date','New-ScheduledTaskAction','New-ScheduledTaskSettingsSet','New-ScheduledTask','Register-ScheduledTask','Get-Childitem','Get-ScheduledTask','New-ScheduledTaskTrigger','out-file','get-item'

What is a problem with this provider ? How could i add it ?

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-09-08T14:54:50.49+00:00

    Hello there,

    Might be a permission or role issue within the scipt.

    When creating a JEA endpoint, you need to define one or more role capabilities that describe what someone can do in a JEA session. A role capability is a PowerShell data file with the . psrc extension that lists all the cmdlets, functions, providers, and external programs that are made available to connecting users.

    Registering JEA Configurations https://learn.microsoft.com/en-us/powershell/scripting/learn/remoting/jea/register-jea?view=powershell-7.3

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  2. Kirill 26 Reputation points
    2023-09-11T05:43:24.43+00:00

    The reason was, that i have to add FileSystem provider to . psrc file

    VisibleProviders = 'FileSystem'

    After this everything work fine

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.