如何从 nushell 运行 powershell 命令

waf*_*fel 6 windows shell powershell nushell

在我的Windows环境中安装nushell(https://www.nushell.sh/)后,我想与powershell结合使用nushell的强大功能。

例如,我需要在日常工作中调用常见的powershell命令,例如

> get-service *myservice -computername remote | restart-service
Run Code Online (Sandbox Code Playgroud)

但是如何从 nu shell 调用这样的命令(使用管道)?

我需要从 powershell 启动 nu shell 还是反之亦然?另外,使用 ^ 符号的调用似乎不起作用。我总是收到“命令未找到”的消息,并且可以肯定它不是 DOS 命令。

如果能在 Windows 上同时获得两个世界的力量就好了……nu shell 和 powershell

rip*_*ey_ 2

您可以使用标志在-commandPowerShell中运行一次性命令。

因此,从 Nu(或 cmd.exe 或任何其他 shell)中,类似这样的操作将起作用:

pwsh -command "echo 'Hello from PowerShell'"
Run Code Online (Sandbox Code Playgroud)

(如果您想要较旧的 Windows Powershell 版本,您可能需要替换pwsh为)powershell