Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell ssh command executing

$
0
0

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?

Powershell
Powershell
$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)"fiecho "${distroname}"'@$LNXver2=(Invoke-SSHCommand-ComputerName$linuxhost-Command$LNXver).result

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>