Boost Productivity With Windows PowerShell Automation

Windows PowerShell offers personalized scripting, advanced automation and productivity solutions for administrators and power users. PowerShell has become the ace in the hole when it comes to system automation.

The PowerShell command cmdlets allow you to do similar tasks that you would do with the admin portals but do them in scripting where you can sequentially execute multiple commands or pipe output from one to automate common tasks.

Microsoft offers many free scripts on the “Script Resources for IT Professionals” web page that you can download, use, or add to. Make sure the script is as up-to-date as possible and has a good rating. The download page also shows which operating systems the script has been released for. The license conditions of the scripts are also displayed when downloading.

Learning to create scripts. A great PowerShell YouTube tutorial resource can be found here on on ScriptRunner.

PowerShell is the most powerful automation tool that Microsoft has to offer, and its both a shell and a scripting language. Geek School has a great tutorial on “Learn How to Automate Windows with PowerShell” here.

Windows PowerShell is not going away any time soon. Most Microsoft products will eventually use it and It can make your life easier (automation). Take advantage of it!

What is a Unix grep Command and how does it relate to the Mac Terminal and Windows PowerShell?

Unix is an operating system. It supports multitasking and multi-user functionality. Unix is most widely used in all forms of computing systems such as desktop, laptop, and servers. On Unix, there is a Graphical user interface similar to windows that support easy navigation and support environment.

The top reason for the popularity of Unix Shell Scripting is its robust scope and command line automation. It’s a powerful programming method that can help you learn the command-line better, and makes it easy to understand basic Mac Terminal and Windows PowerShell commands. PowerShell brings the functionality of grep equivalent with the Select-String cmdlet.

grep is a Unix command-line utility for searching plain-text data sets for lines that match a regular expression. Think of it a “search” or “find” command in Unix. Most basic Unix command forms like grep relate to the present Mac Terminal and Windows PowerShell commands. PowerShell is superficially similar to Unix shells. PowerShell has aliases for many of the commands you are used to in Unix, like ls, rm, cp, mv, etc.

The grep command is a filter that is used to search for lines matching a specified pattern and print the matching lines to standard output.

The syntax is:

grep ‘<text-to-be-searched>’ <file/files>

Note that single or double quotes are required around the text if it is more than one word. You can also use the wildcard (*) to select all files in a directory.

If its a one word search, example below (serach for the name “financial” in a file called “advisor”):

grep financial advisor

Grep will display every line where there is a match for the word financial. When executing this command, you do not get exact matches. Instead, the terminal prints the lines with words containing the string of characters you entered.

Say you want to search all files in a Directory. How do you do that?

To search all files in the current directory, use an asterisk instead of a filename at the end of a grep command.

Example, we use financial as a search criterion:

grep financial *

A good UNIX For Dummies Cheat Sheet is here. Unix operates and command line syntx carries over into other OS like MacOS and Windows. Its a good to review how Unix basic commands work when trying them out on your Mac and Windows equivalent automation manager.