about
MLiPS 4
11/22/2024

MLiPS 4: PowerShell

scripting with object passing pipelines

Mike Corley
click header to toggle Site Explorer

What is PowerShell?:

What is PowerShell? a task-based command-line shell and scripting language built on .NET.
PowerShell has been an integral part of Windows since Windows 7. Another version, called PowerShell Core runs on .Net Core, which is a cross-platform execution evironment available on Windows, macOS, CentOS, and Ubuntu.
Used by system administrators and power-users to rapidly automate tasks that manage operating systems (Linux, macOS, and Windows) and processes.
"PowerShell can execute four kinds of named commands:
  • cmdlets (.NET Framework programs designed to interact with PowerShell)
  • PowerShell scripts (files suffixed by .ps1)
  • PowerShell functions
  • standalone executable programs
If a command is a standalone executable program, PowerShell launches it in a separate process; if it is a cmdlet, it executes in the PowerShell process." - wikipedia.

PowerShell Cmdlets

CMDLETs ("command-let") are simple, single-function command-line tools registered with the shell. Each is an instance of a .Net class that derives from System.Management.Automation.Cmdlet or its sister PSCmdlet.
They can be combined, using the pipe "|" operation to form complex processing pipelines.
An example is shown in Figure 3, where the output from the cmdlet Get-Service is piped into the cmdlet Where-Object, with a (Where-Object) command line qualifier "$_.Status -eq "Running".
Another example is shown in Figure 4, where the PowerShell script host was started with the "PowerShell" command. Here, the output of Get-ChildItem with command line argument "$dirname" is piped to the filter "Select-Object with option "-ExpandProperty FullName"

PowerShell Applications:

PowerShell has been integrated into many frameworks/tools and cloud orchestration environments. Two well-known examples are Amazon AWS and Microsoft Azure.
https://en.wikipedia.org/wiki/PowerShell
https://ss64.com/ps/syntax.html
https://docs.microsoft.com/en-us/powershell/developer/windows-powershell?redirectedfrom=MSDN
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipelines?view=powershell-6"
https://aws.amazon.com/powershell/
https://docs.microsoft.com/en-us/powershell/azure/get-started-azureps?view=azps-2.7.0
  Next Prev Pages Sections About Keys