Share via


i need a PowerShell script that will remotely log into a Linux server and gather all user info

Question

Tuesday, August 20, 2019 7:31 AM

i am new to Powershell and recently i got a task to build a PowerShell script that will remotely log into a Linux server and gather all user info for that Linux Server and parse it into an excel sheet for a report. please help.

All replies (4)

Friday, August 23, 2019 11:07 AM âś…Answered

Hi all, 

Just as another option, I would like to metion about PoSH-SSH module, which could be found at:

https://www.powershellgallery.com/packages/Posh-SSH/2.2

It contains a command Invoke-SSHCommand, which "executes a given command on a remote SSH host".

https://github.com/darkoperator/Posh-SSH/blob/master/docs/Invoke-SSHCommand.md

I used it once for a project with a FreeBSD machine and it worked just fine, without the need of any special prerequisites. 

Hope it helps. 

Best regards, 

Ivan 


Tuesday, August 20, 2019 8:37 AM

Please read the very first post on top of the list of this forum: Forum Posting Guidelines.

Live long and prosper!

(79,108,97,102|%{[char]$_})-join''


Tuesday, August 20, 2019 9:45 AM

Hi Muhammad,

we cannot write the script for you, butr we can surely guide you on how you can do this on your own. So, let's get you started. In order to connect to a Linux Server using PowerShell the easiest (in my opinion) way would be to leverage PowerShell Remoting over SSH. Here 3 sources, which will help you connect to a Linux system, using PowerShell over SSH:

PowerShell Remoting Over SSH

Using SSH to Access Linux Servers in PowerShell

and a nice video tutorial:

How To Use PowerShell Remoting Over Secure Shell (SSH)

The next step would be to query the Linux system for the information you need. Those articles have also nice example on how to query different information, using PowerShell and will help you build your script:

PowerShell to query Linux systems remotely from Windows

Linux + PowerShell = Awesome, Not Awkward, Together!

Hope this helps you out. Regards,

(Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov


Friday, August 23, 2019 7:49 PM

Thanks for help