PowerShell和cmd.exe命令语法有什么区别?

Bun*_*nyk 5 powershell cmd winrm

我在PowerShell中运行以下命令:

PS C:\Users\adminaccount> winrm s winrm/config/service @{AllowUnencrypted="true";
MaxConcurrentOperationsPerUser="4294967295"}
Error: Invalid use of command line. Type "winrm -?" for help.
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,这给了我一个错误.但cmd.exe中的相同命令工作正常:

C:\Users\adminaccount>winrm s winrm/config/service @{AllowUnencrypted="true";
MaxConcurrentOperationsPerUser="4294967295"}
Service
...
Run Code Online (Sandbox Code Playgroud)

那么,我应该了解PowerShell语法以使其在那里工作?

Ans*_*ers 6

@{}在PowerShell中定义哈希表,但winrm需要一个字符串参数.如果要直接在PowerShell中运行该命令,请将该参数放在引号中:

winrm s winrm/config/service '@{AllowUnencrypted="true"; MaxConcurrentOperationsPerUser="4294967295"}'
Run Code Online (Sandbox Code Playgroud)

此外,您需要管理员权限才能工作.