Automating Command Line Sessions with Powershell

James Livingston shows us how to redirect the standard in flow with .NET, using Powershell as the example language:

Command Line Interface (CLI) tools can be very useful for interacting with certain applications. However, some CLIs do not let a user pass in parameters which makes it difficult to automate. Instead, they lock a user into an interactive session and force the user to enter commands. Fortunately, some programming languages allow for a redirection of the standard input, output, and error of an running process. A developer co-worker of mine has been very successful doing this in Java, which got me thinking… And turns out, using the .NET libraries, we can implement this functionality for any CLI in PowerShell.

Automating interactions with CLI programs is often not ideal but when you’re stuck, it does the trick.

Related Posts

Quick Thoughts on Dot-Sourcing in Powershell Modules

Cody Konior wants to speed up module loading: One of the more heated ideas is that you should combine all of your scripts into a massive file and execute it once instead. Currently dbatools uses a mix of these techniques in great detail and to great success. I don’t want to use a single file because I […]

Read More

Micro Modules in Powershell

Kevin Marquette shows how to create a micro module and explains why you might want one: A micro module is very small in scope and often has a single function. Building a micro module is about getting back to the basics and keeping everything as simple as possible. There is a lot of good advice […]

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories

April 2019
MTWTFSS
« Mar  
1234567
891011121314
15161718192021
22232425262728
2930