Why my external script not running in JEA PowerShell session?

Ádám Tóth 116 Reputation points
2021-07-13T11:07:42.437+00:00

Hi,

I created a JEA configuration on a Remote Server, everything works except an external script what I specified in the VisibleExternalCommands section in the psrc file:

VisibleExternalCommands = 'C:\temp\Restart_Computer.ps1'

The script would do to restart the Server and it looks like this:

Restart-Computer -ComputerName localhost -Force

However, for some reason it doesn't like the -Force parameter.

Always writes this:
a parameter cannot be found that matches parameter name "Force"

After I tried something. I put this one extra line in my script (and commented the restart part):

Copy-item -Path C:\temp\a.txt -destinaton C:\temp\1 -Force

and it worked.

It copied the txt file without any issue and didn't has problem with the Force parameter. 

What could be the problem with the Restart-Computer and Force together?

The script runs without any issue outside of JEA remote session.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ádám Tóth 116 Reputation points
    2021-07-14T12:29:11.523+00:00

    I found the error.

    I left a line in VisibleCmdlets which contained "Restart-Computer" command but without Force parameter.

    So thats why JEA didn't let my script running.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 45,906 Reputation points
    2021-07-13T14:57:53.957+00:00

    I've never uses JEA, but perhaps the "-Force" isn't allowed for that Cmdlet or user?

    0 comments No comments

  2. Ádám Tóth 116 Reputation points
    2021-07-14T08:51:47.597+00:00

    He has permission, he uses JEA as virtual Administrator.

    0 comments No comments