键入 cmdlet:Get-Service ssh
或者,停止服务 ssh
或者,启动服务 ssh
PowerShell => Linux
获取服务 ssh => 服务 --status-all
启动服务 ssh => 服务 ssh 启动
停止服务 ssh => 服务 ssh 停止
三个 cmdlet 中的任何一个都会出现以下错误:
xxx-service :术语“xxx-service”不被识别为 cmdlet、函数、脚本文件或可操作的名称
程序。
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
除了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>
最有用的评论
嗨任何进展:-)
*-Service
可能是移植到 linux 的最重要的 cmdlet,我对 powershell 的大部分用途是创建和管理服务,因为与 sc、nssm.exe、sysinit 和 systemd 相比,它是如此简单。Systemd 现在被大多数 linux 使用。 我热切地等待着这个。
甚至 Raspbian 也有 systemd