Original Research on Combining The Power of Windows and Linux
Introduction
Combine the power of Bash on Linux and PowerShell on Windows to create tools that are greater than the sum of their parts.
Windows || Linux
For a long time, in the IT world, Linux and Windows admins often practiced a form of social distancing. You were either in the Windows camp, or the Linux camp. Linux providers such as SUSE, Canonical, and others along with Microsoft have decided to tear down this wall that separates these two technologies. You can too! This article demonstrates a very practical way to leverage the strengths of both Windows and Linux. See these instructions for installing WSL.
Linux && Windows
I have a Windows 2019 Server and from a PowerShell prompt I can type: bash and “ahhh...” I’m at home! To do this, I installed Windows Subsystem for Linux (WSL) and I then chose to install Ubuntu as my Linux distribution. I have also done the same installation to my Windows 10 box so that my bash terminal is always close by. See: How to run Linux on Windows Server 2019 with WSL for detailed instructions on how to do this.
Windows + Linux
I’ve created a solution that uses a PowerShell script (port_check.ps1) plus a Bash script (port_check.sh) which need each other in order to create a server address and port check solution. The entry point to the solution is a PowerShell script. The Linux Bash script does the actual address and port check.
You could create this solution with PowerShell alone, without Linux, but that isn’t the point of this exercise. What I am trying to demonstrate here is a methodology for leveraging the power of both Linux and Windows, . . . it’s like having both an SUV -and- a sports car in your garage.
Installing Cimitra’s Check Port Solution
[INSTALL]
In a Bash terminal on the Windows box DOWNLOAD AND RUN the install script as shown on the next line below, (NOTE: Get the entire next line)
curl -LJO https://raw.githubusercontent.com/cimitrasoftware/blog_scripts/master/port_check_install.sh -o ./ ; chmod +x ./port_check_install.sh ; ./port_check_install.sh
[RUN]
Now open up a Windows PowerShell terminal and run the check_port.ps1 script.
c:\linwin\port_check.ps1 <address> <port>
Example:
c:\linwin\port_check.ps1 192.168.99.1 443
Just for fun, back at your Bash terminal, you can actually run the PowerShell script from Bash in the following manner:
powershell.exe "c:\linwin\port_check.ps1" 192.168.99.1 443
Conclusion
For myself, this methodology means that if I prefer the way something is done in Bash, I can just port that functionality over to my PowerShell scripts.
If you think you need to be in a Windows camp vs. a Linux camp, . . . well, you need to get up to speed. That’s the old way of doing things. There are so many more options when you combine the strengths of Linux and Windows.
Splunk | Ex-DocuSign
4 年Tay Kratzer it’s great how the tools for administration are crossing over. Very informative! #cimitra #cimitra