PowerShell core on Linux - Get-Service should mimic linux "service" command.
Steps to reproduce
Type the cmdlet: Get-Service ssh Or, Stop-Service ssh Or, Start-Service ssh
Expected behavior
PowerShell => Linux Get-Service ssh => service --status-all Start-Service ssh => service ssh start Stop-Service ssh => service ssh stop
Actual behavior
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.

Environment data
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>
Hi, any new progress with implementing Start-Service for Linux? I would really appreciate it.
6 years later and no change on this?
There is the nxtools module that has wrappers for common Linux utilities.
https://github.com/PowerShell/PowerShell/issues/3582#issuecomment-294551258
@joeyaiello, almost all distributions nowadays use systemd for that same reason. Trying to automate initialization scripts across distributions was hellish until systemd standardized the API through its marketshare. Consequently, I would wholeheartedly accept an implementation which solely supported systemd.
Proponents of SysVInit etcetera could request or implement their own if it had any kind of extension system built in. Otherwise, they could simply call the binaries without utilizing PowerShell's obfuscation. My expectation is that very few distributions which don't utilize systemd have a significant PowerShell userbase.
Don't allow perfection to be the enemy of good.
https://github.com/PowerShell/PowerShell/issues/3582#issue-222187394
@MaximoTrinidad, why do you propose service rather than calling systemctl?
Okay - I thought there was something wrong with my PowerShell install onto Debian 12 - so it is a bit reassuring to see that I'm not the only person struggling with the "Get-Service" command.
If I'm understanding this correctly, there is no workaround for this, aside from utilizing nxtools? I ask, because even after installing it, there was no change when attempting to run command.
(I'm new to learning how to work with PowerShell - so thanks for your patience!)