Title: `Restart-Service` should call `systemctl restart` on Linux OSes with SystemD present. · Issue #18863 · PowerShell/PowerShell · GitHub
Open Graph Title: `Restart-Service` should call `systemctl restart` on Linux OSes with SystemD present. · Issue #18863 · PowerShell/PowerShell
X Title: `Restart-Service` should call `systemctl restart` on Linux OSes with SystemD present. · Issue #18863 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement I want to be able to restart sshd from Windows and Linux in the same way after modifying sshd_config. This is almost possible, because Get-Content and Set-Content are already cross-platform. Howev...
Open Graph Description: Summary of the new feature / enhancement I want to be able to restart sshd from Windows and Linux in the same way after modifying sshd_config. This is almost possible, because Get-Content and Set-C...
X Description: Summary of the new feature / enhancement I want to be able to restart sshd from Windows and Linux in the same way after modifying sshd_config. This is almost possible, because Get-Content and Set-C...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/18863
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Restart-Service` should call `systemctl restart` on Linux OSes with SystemD present.","articleBody":"### Summary of the new feature / enhancement\n\nI want to be able to restart `sshd` from Windows and Linux in the same way after modifying sshd_config. This is almost possible, because `Get-Content` and `Set-Content` are already cross-platform. However, I currently must interact with the init-system when restarting services on Linux, despite an abstraction for `net` and `sc` (`Restart-Service`) already existing in PowerShell, and the potential solution being, I expect, so easy.\n\n#### Attempt\n\n1.\t~~~PS1\n\t#!/usr/bin/env pwsh\n\tRestart-Service 'sshd'\n\t~~~\n\n\t[^2]\n\n\t[^2]: [`MicrosoftDocs/PowerShell-Docs/blob/d2da3d7eede5c03b81c26f28d4ba5a67bc200a90/reference/docs-conceptual/security/remoting/SSH-Remoting-in-PowerShell.md#install-the-ssh-service-on-a-windows-computer`](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/d2da3d7eede5c03b81c26f28d4ba5a67bc200a90/reference/docs-conceptual/security/remoting/SSH-Remoting-in-PowerShell.md#install-the-ssh-service-on-a-windows-computer)\n\t\n1.\tHowever, this produced:\n\n\t\u003cblockQuote>\n\t\n\t~~~YAML\n\tRestart-Service: The term 'Restart-Service' is not recognized as a name of a cmdlet, function, script file, or executable program.\n\tCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\n\t~~~\n\n\t\u003c/blockQuote>\n\n### Proposed technical implementation details (optional)\n\nCall `systemctl restart sshd`, if `Get-Command systemctl` returns `True`:\n\n1.\t~~~PS1\n\t#!/usr/bin/env pwsh\n\tsystemctl start 'sshd' && `\n\tjournalctl -fexu 'sshd'\n\t~~~\n\n\t[^1]\n\n\t[^1]: [`serverfault.com/revisions/858700/1`](https://serverfault.com/revisions/858700/1)\n\t\n1.\t\u003cblockQuote>\n\t\n\t~~~ma \n\tDec 28 18:29:10 beedell.rokejulianlockhart.1669806072 systemd[1]: Starting sshd.service - OpenSSH server daemon...\n\t░░ Subject: A start job for unit sshd.service has begun execution\n\t░░ Defined-By: systemd\n\t░░ A start job for unit sshd.service has begun execution.\n\t░░ The job identifier is 322.\n\tDec 28 18:29:10 beedell.rokejulianlockhart.1669806072 sshd[1412]: Server listening on 0.0.0.0 port 22.\n\tDec 28 18:29:10 beedell.rokejulianlockhart.1669806072 sshd[1412]: Server listening on :: port 22.\n\t~~~\n\t\n\t\u003c/blockQuote>","author":{"url":"https://github.com/beedell-roke","@type":"Person","name":"beedell-roke"},"datePublished":"2022-12-28T19:00:47Z","url":"https://github.com/PowerShell/PowerShell/issues/18863"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e8822e8b-60f8-4a22-c9ea-690fbaff5062 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E956:46EFB:5F06D:80C88:6AFD3820 |
| html-safe-nonce | 56e69769906a5f16e6b4175d9dbb53295a6ec798e5ff58f813c70e788b44357d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTU2OjQ2RUZCOjVGMDZEOjgwQzg4OjZBRkQzODIwIiwidmlzaXRvcl9pZCI6Ijg4NjU4MjYzMzIwNjQxNjc5NjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f0d2424bc0b7a87d6007f140dae7d2e40e5a11bd75b3928d3deb2ae7331707e3 |
| hovercard-subject-tag | issue:1513075385 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/18863/issue_layout |
| twitter:image | https://opengraph.githubassets.com/adae6d6016379b366b55a21939d7172fe0f547d625257893d7449a614f2f32d5/PowerShell/PowerShell/issues/18863 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/adae6d6016379b366b55a21939d7172fe0f547d625257893d7449a614f2f32d5/PowerShell/PowerShell/issues/18863 |
| og:image:alt | Summary of the new feature / enhancement I want to be able to restart sshd from Windows and Linux in the same way after modifying sshd_config. This is almost possible, because Get-Content and Set-C... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | beedell-roke |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width