Making the Most of PowerShell Automation – More than Just Sending Email
PowerShell Core is an open-source and cross-platform Microsoft command line tool in Windows that allows programmers to write commands, or Cmdlets, that help automate administrative tasks. SocketLabs has published helpful new PowerShell script examples on GitHub and the PowerShell Gallery that will allow customers to send numerous command outputs through our Injection API.
What is PowerShell and Where did it Come From?
Microsoft has included a command line interpreter or CLI in Windows since their earliest personal computers. The early CLI was designed to manage the operating system which supported only basic internal commands. Because of its simplicity, this CLI only allowed for limited task automation in Windows; anything more complex required a separate console application to be written.
Microsoft continuously developed and improved its CLI in new Windows versions but experienced ongoing growing pains throughout these advancements. One notable example is the well-known vulnerability of Windows Script Host, where automation in Windows applications and processes allowed room for easily writable viruses and malware to be implanted.
By 2002, Microsoft had a new approach to command line management with a CLI called Microsoft Shell. Microsoft Shell was continuously developed and advanced in different versions. By 2016, it became open-source and cross-platform and is now known as PowerShell Core.
Now, PowerShell Core is used by companies and private parties to build open-source command line software across platforms that can automate repetitive administrative tasks. For example, users can set up commands like the:
- “If” condition that prompts a certain action if something is true
- “Do While” loop that tells PowerShell to do a certain task while something remains true
- “Get-Help” command that provides more information on any given command for new-comers to familiarize themselves with the language
- “Get-Item” command that tracks down information on any given item such as a file on your hard drive
- “Send-MailMessage” command that sends emails from within PowerShell
These examples and thousands others like it can be set up to run on a manual or automated basis.
Using PowerShell to Send Email with SocketLabs
At SocketLabs, we have developed a number of open source libraries that will help customers send messages through our Injection API. The SocketLabs PowerShell module implements our SocketLabs-CSharp library to send message directly from PowerShell.
Using the unique SocketLabs PowerShell module, you can send a list of processes to an email recipient, get IP address information from hosts, and even work around the dreaded “Port 25 Blocked” error. You can find these PowerShell examples and more, published by SocketLabs, on GitHub and the PowerShell Gallery. The SocketLabs PowerShell Module is currently available for Windows, Mac and Linux. We are continuously working to create additional support for our other platform API’s.
For those looking to take advantage of our PowerShell module, there are a couple quick prerequisites and installation requirements that you should consider first.
- A supported .NET version
- PowerShell 5.1 or PowerShell Core 6.1.0 or higher.
- .NET version 4.6.1 or higher
- .NET Standard 2.0 or higher
- A SocketLabs account. If you don’t have one yet, you can sign up for a free account to get started
For most uses we recommend installing the SocketLabs PowerShell Module via the PowerShell Gallery. You can install the latest version of the module with the following command:
PS> Install-Module -Name SocketLabs -Force
Alternately, you can simply clone this repository directly to include the source code in your project.