darkoperator / darkoperator/Posh-SSH

Extract linux version for all distribution

Open
#261 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
1.1k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

Hi guys,
i need to send these commands through any powershell ssh module in order to return the correct version of the operating system based on the distribution.
If I open putty and paste the code, it works without problems, if I use any module (posh-ssh or others) when I send this command, the output is an error.
Can anyone tell me why?

`$linuxhost = '192.168.10.207'

$LNXver = @'
/bin/bash<arch=$(uname -m)
kernel=$(uname -r)
if [ -n "$(command -v lsb_release)" ];
then distroname=$(lsb_release -s -d)
elif [ -f "/etc/os-release" ];
then distroname=$(grep PRETTY_NAME /etc/os-release | sed 's/PRETTY_NAME=//g' | tr -d '="')
elif [ -f "/etc/debian_version" ];
then distroname="Debian $(cat /etc/debian_version)"
elif [ -f "/etc/redhat-release" ];
then distroname=$(cat /etc/redhat-release)
else distroname="$(uname -s) $(uname -r)"
fi
echo "${distroname}"
'@
$LNXver2 = (Invoke-SSHCommand -ComputerName $linuxhost -Command $LNXver).result `

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the multiline /bin/bash command passed to Invoke-SSHCommand and compare its behavior with the same command in PuTTY. Capture the module's error output and determine whether the command can return the Linux distribution version through the SSH module.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, linux, powershell
Domain
cli, devops, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.