<p>Linux 上的 PowerShell 核心 - Get-Service 应该模仿 linux 的“服务”命令。</p>

创建于 2017-04-17  ·  3评论  ·  资料来源: PowerShell/PowerShell

重现步骤

键入 cmdlet:Get-Service ssh
或者,停止服务 ssh
或者,启动服务 ssh

预期行为

PowerShell => Linux
获取服务 ssh => 服务 --status-all
启动服务 ssh => 服务 ssh 启动
停止服务 ssh => 服务 ssh 停止

实际行为

三个 cmdlet 中的任何一个都会出现以下错误:
xxx-service :术语“xxx-service”不被识别为 cmdlet、函数、脚本文件或可操作的名称
程序。
xx-service_2017-04-17_13-59-44

环境数据

Linux Ubuntu 桌面 16.04.2

PS /home/maxt> $PSVersionTable                                                                                          
Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.18
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Area-Cmdlets-Management Issue-Enhancement OS-Linux OS-macOS Up-for-Grabs

最有用的评论

嗨任何进展:-)

*-Service可能是移植到 linux 的最重要的 cmdlet,我对 powershell 的大部分用途是创建和管理服务,因为与 sc、nssm.exe、sysinit 和 systemd 相比,它是如此简单。
Systemd 现在被大多数 linux 使用。 我热切地等待着这个。

甚至 Raspbian 也有 systemd

# cat /proc/cpuinfo | grep model | head -1
model name      : ARMv7 Processor rev 5 (v7l)
# cat /etc/debian_version
9.1
# systemctl | grep service | wc -l
41
# pwsh
PowerShell 6.1.0
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /root> Get-Command | Measure-Object -line
Lines Words Characters Property
----- ----- ---------- --------
  323

PS /root> Get-Command | select-string -Pattern "Service"
PS /root>

所有3条评论

除了service仅在 systemd 机器上可用。 这就是为什么这很棘手。 我们基本上需要实现这种行为两次(或三四次)。

我同意我们开始使用 powershell 来管理可能是也可能不是 Windows 的 azure 部署

嗨任何进展:-)

*-Service可能是移植到 linux 的最重要的 cmdlet,我对 powershell 的大部分用途是创建和管理服务,因为与 sc、nssm.exe、sysinit 和 systemd 相比,它是如此简单。
Systemd 现在被大多数 linux 使用。 我热切地等待着这个。

甚至 Raspbian 也有 systemd

# cat /proc/cpuinfo | grep model | head -1
model name      : ARMv7 Processor rev 5 (v7l)
# cat /etc/debian_version
9.1
# systemctl | grep service | wc -l
41
# pwsh
PowerShell 6.1.0
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /root> Get-Command | Measure-Object -line
Lines Words Characters Property
----- ----- ---------- --------
  323

PS /root> Get-Command | select-string -Pattern "Service"
PS /root>
此页面是否有帮助?
0 / 5 - 0 等级