Type the cmdlet: Get-Service ssh
Or, Stop-Service ssh
Or, Start-Service ssh
PowerShell => Linux
Get-Service ssh => service --status-all
Start-Service ssh => service ssh start
Stop-Service ssh => service ssh stop
Any of the three cmdlets will give the following errors:
xxx-service : The term 'xxx-service' is not recognized as the name of a cmdlet, function, script file, or operable
program.
Linux Ubuntu Desktop 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
Except that service
is only available on systemd machines. That's why this is tricky. We basically need to implement this behavior two (or three or four) times.
I agree as we start using powershell for managing azure deployments which may or may not be windows
Hi any progress :-)
*-Service
is probably the most important cmdlets to be ported to linux, Most my use of powershell is to create and manage services because it is so simple compared to sc, nssm.exe, sysinit and systemd.
Systemd is now used by most linuxes. I'm eagerly awaiting this.
Even Raspbian have 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>
Most helpful comment
Hi any progress :-)
*-Service
is probably the most important cmdlets to be ported to linux, Most my use of powershell is to create and manage services because it is so simple compared to sc, nssm.exe, sysinit and systemd.Systemd is now used by most linuxes. I'm eagerly awaiting this.
Even Raspbian have systemd