Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell core on Linux - Get-Service should mimic linux "service" command. #3582

Open
MaximoTrinidad opened this issue Apr 17, 2017 · 9 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug OS-Linux OS-macOS Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module

Comments

@MaximoTrinidad
Copy link

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.
xx-service_2017-04-17_13-59-44

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
@joeyaiello
Copy link
Contributor

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.

@joeyaiello joeyaiello added WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors Issue-Enhancement the issue is more of a feature request than a bug OS-Linux OS-macOS labels Apr 17, 2017
@rahulguha
Copy link

I agree as we start using powershell for managing azure deployments which may or may not be windows

@fenchu
Copy link

fenchu commented Jan 25, 2019

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>

@pat0s
Copy link

pat0s commented Sep 7, 2022

Hi, any new progress with implementing Start-Service for Linux? I would really appreciate it.

@brolifen
Copy link

6 years later and no change on this?

@ThomasNieto
Copy link
Contributor

There is the nxtools module that has wrappers for common Linux utilities.

@RokeJulianLockhart
Copy link

RokeJulianLockhart commented Dec 17, 2023

#3582 (comment)

@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.

@RokeJulianLockhart
Copy link

#3582 (comment)

@MaximoTrinidad, why do you propose service rather than calling systemctl?

@priestapostate1208
Copy link

priestapostate1208 commented Feb 7, 2024

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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug OS-Linux OS-macOS Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module
Projects
None yet
Development

No branches or pull requests

9 participants