简体   繁体   中英

Invoke-Command is giving NativeCommandError

I am using Invoke-Command { & "powershell.exe" } -NoNewScope and getting error as belove.

powershell.exe : Loading personal and system profiles took 1761ms.
At line:1 char:18
+ Invoke-Command { & "powershell.exe" } -NoNewScope
+                  ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Loading persona...es took 1761ms.:String 
   ) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Error Image

This is...

Invoke-Command { & "powershell.exe" } -NoNewScope

... is for the console host based on your use case.

If you are in the ISE, 在此处输入图像描述

... you must use New PowerShell Tab option, to get a new session and your profile will load there.

在此处输入图像描述

You can use the shortcut key of course. CRTL+T

在此处输入图像描述

Differences between the ISE and PowerShell console - PowerShell Team

Console Application (Non) Support in the ISE

$psUnsupportedConsoleApplications
# Results
<#
wmic
wmic.exe
cmd
cmd.exe
diskpart
diskpart.exe
edit.com
netsh
netsh.exe
nslookup
nslookup.exe
powershell
powershell.exe
ssh-keygen
ssh-keygen.exe
#>

PowerShell- Running Executables - TechNet Articles - United States (English) - TechNet Wiki

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM