i am new to PowerShell recently i got an 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.
need help in this regards Thanks.
You cannot log on to any host without using the proper credentials.
Since you say you are new to PowerShell, it is vital you spend the time getting up to speed on it as to limit / avoid, misconceptions, bad habits, bad code, errors, confusion or seriously damaging your environment.
There are tons for free / no costs / cost resources for you to leverage.
You also have several steps to learn based on your ask:
PowerShellPowerShell remotingLocal / remote variable usePowerShell using LinuxCredential use / ManagementUsing the Excel Component Object model with PowerShell
Never ever, just run any ones code that you do not explicitly know what it s going to do in your environment.
Windows PowerShell Survival Guide
Purpose of this Document The purpose of this document is to help you to learn more about PowerShell and to be successful in applying it. This document seeks to point to the best content on the web to enable you to reach that goal.
Scope of this DocumentThis page contains links to help you learn more about Microsoft Windows PowerShell. This includes PowerShell fundamentals as well as how PowerShell is used in Windows applications and services. As long as it's PowerShell related, we'll try to point to it! The document is also version agnostic, and contains information about current and future versions of PowerShell.
See also posts here for other resource suggestions here:
Learning this stuff.https://www.reddit.com/r/PowerShell/comments/bserj9/learn_powershell/eooduq9/?context=3 https://www.reddit.com/r/PowerShell/comments/bserj9/learn_powershell/eoodxzu/?context=3
Practice with PSKoans
PSKoans : 0.50.0 A module designed to provide a crash-course introduction to PowerShell with programming koans.https://www.powershellgallery.com/packages/PSKoans/0.50.0
Come to know your dev tools / environments:Built into Windows PowerShell ISE (though no more work is going into it, Micros has already said, it will always be in the OS).
Visual Studio Code, then new hotness, for developers, and scripters. It takes a while to get it configure for all you will need, and provides far more that the ISE does.
Sapien's PowerShell studio is the first class / top tier full IDE for PowerShell, but it not a inexpensive one, but well worth the price IMHO.https://www.sapien.com/software/powershell_studio
Learn to use both, as in most cases, data center servers will not have VSCode, but the ISE is in the box.
There are a bunch of add-one / extensions for both.
Then of course you can use full Visual Studio for PowerShell script, GUI, module development. As you can with VSCode, just be sure to purchase the full PowerShell Pro Tools addon for PowerShell project. It's $59.00, so, in expensive, though to continue to get updates for it, that is an annual cost.
How to use Remote Commands with PowerShell (Windows / Linux / OSX), even using SSH is fully documented by Microsoft and described on many other sites / blogs / Q&A sites all over the web.
Searching for 'powershell ssh remoting', will give you a very long list of topics and samples:
Running Remote Commandshttps://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-6
PowerShell Remoting Over SSHhttps://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core?view=powershell-6
PowerShell Remoting using SSH!https://devblogs.microsoft.com/powershell/powershell-remoting-using-ssh
PowerShell: Use SSH to connect to remote hosts (Posh-SSH)https://sid-500.com/2017/09/03/powershell-use-ssh-to-connect-to-remote-hosts-posh-ssh
Why Remoting vs. SSH Isn't Even a Thinghttps://powershell.org/2015/06/why-remoting-vs-ssh-isnt-even-a-thing
PowerShell and Excel Info:https://www.bing.com/search?q=powershell+excel&qs=n&form=QBLH&pc=EUPP_&sp=-1&pq=powershell+excel&sc=8-16&sk=&cvid=02BFA9F90E2145CC93038141B375E305
Thank you very much for you kindly and helpful reply i would be definitely going to check these mentioned resource links. once again thanks
Powered by IDERA