Why my external script not running in JEA PowerShell session?

Ádám Tóth 116 Reputation points


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,347 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ádám Tóth 116 Reputation points

    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 44,621 Reputation points

    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

    He has permission, he uses JEA as virtual Administrator.

    0 comments No comments