Overview#

PowerShell is a multifunctional command shell and scripting language used for automating tasks in Windows. Its capabilities allow for system management, process automation, and the creation of interactive scripts.

powershelldocs.microsoft.com

Ways to Display Data#

  • Output text to the console [Console]::WriteLine("PowerShell")

  • Show a full message box (MessageBox) [System.Windows.Forms.MessageBox]::Show()

  • Input user data (InputBox)

    [Microsoft.VisualBasic.Interaction]::InputBox()

Helper Commands#

  • Call help Get-Help ForEach-Object -Parameter InputObject
  • Pause script execution (delay for 15 seconds) Start-Sleep -s 15

Cmdlets#

Cmdlets are small, purpose-built PowerShell commands that perform a specific function. They have a universal format: verb-noun (for example, Get-Help, Get-Process, Start-Service). Additionally, many cmdlets have short aliases for quick invocation:

  • Get-Processgps
  • Out-GridViewogv

This helps speed up work and write compact code.

  • View properties and methods of a process object: Get-Process | Get-Member
  • Visual interactive data view: Get-Process | Out-GridView
    • Data is displayed in a convenient table format, allowing the user to manually sort and filter items by various parameters.
    • Just type in the Sherpa console: $Object | Out-GridView, and a window with data will open, allowing you to view the contents of variables during debugging.
    • Easily integrate into Robot code in Sherpa Designer to display data during script execution. Each such window will remain open while the code is running (i.e., the window will close when the script execution ends or the stop execution button is pressed).

More details or here or in the documentation.

Lexical Structure #

chapter 02learn.microsoft.com

Arithmetic Operations#

about_arithmetic_operatorslearn.microsoft.com

PowerShell supports standard arithmetic operations and can be used for complex calculations.

For example, measuring the execution speed of a block of commands: 1..10 | Measure-Command -Expression { <expression> }, where Measure-Command allows you to determine the execution time of a specific expression.