# Symbols and Operators

## Basic

* `#` - comments
* `<#...#>` - comment with delimiters
* `` ` `` - indicates special characters within quotes
* `-` (dash) - placed before the names of function/commandlet/letter operator parameters
* `%` - mathematical operator that returns the remainder of division (`11 % 5 = 1`)
* `%{}` – replaces the `ForEach-Object` commandlet
* `;` - line separator (to write multiple lines in one line of code)
* `=` - assignment operator
* `&{}` – embeds a scriptblock in an expression
* `?` - replaces the `Where-Object` commandlet
* `:` - for specifying switch parameters
* `.` – accesses dynamic class methods (`$datatable.Rows.Count`)
* `..` – range separator (`1..4 = @(1,2,3,4)`)
* `::` – accesses static class methods (`[Console]::WriteLine("PowerShell")`)
* `@` - array operator:
  * forces a value to be an array, even if it is single-element or null;
  * can create hash tables: `@{"Key" = "Value";"Key2"="Value2"}`
  * used for Splatting, i.e., passing function parameters as an array or dictionary (`@arr / @dic`)
* `|` - pipeline (like a lambda):
  * `($obj| \cmdlet\) / ($collection[]| \cmdlet\)` - executes a commandlet for an object;
  * `$collection=@()| Foreach-Object{$_}` - loop where `$_` is used as the iterator;
  * `($proc = Get-Process Notepad* ) | Stop-Process` - kills all processes containing `Notepad` in the name and returns all killed processes in `$proc`;
  * `(Get-Process Notepad* ) | Stop-Process` - without returning the list.

## Comparison Operators

* `-match "#pattern#"` - using regular expressions
* `-is [type]` - type checking
* `-isNot [type]` - type checking

More about comparison operators, arithmetic, and logical operators:

{% embed url="<https://docs.sherparpa.ru/obuchenie-po-razrabotke-na-platforme-sherpa-rpa/obuchenie-powershell#id-2.-operatory-sravneniya-v-powershell>" %}

## Conditions in Arrays

* `-$array -\comparison operator\ $obj` - returns an array of objects resulting from matching each element with the object, or False (a non-empty array equals True for logical expressions)
* `-contains` - array contains the object (bool)
* `-notcontains` - array does NOT contain the object (bool)
* `-in` - object is in the array (bool)
* `-notin` - object is not in the array (bool)

> contains & in differ in notation $arr -contains $obj / $obj -in $arr

## Parentheses

* `()` – Round brackets:
  * passing arguments,
  * grouping multiple statements (for example),
  * resolving ambiguity (actions in parentheses are executed first),
  * creating arrays.
* `{}` - Curly brackets:
  * grouping statements (for example, in an if block),
  * embedding a script in an expression (scriptblock).
* `[]` - Square brackets:
  * accessing elements of arrays and hash tables,
  * filtering using regular expressions,
  * specifying the expected data type for an expression,
  * accessing a namespace.

## Quotes

* `" "` - allow placing a variable name inside, automatically converting it to its value.
* `' '` - allow placing a variable name inside, but do NOT convert it to its value.

> Quotes support multiline code (ENTER moves to the next line of code, \`n - newline in output).

> Quotes are escaped with a double quote (as in VB) + single quotes do not need to be escaped inside double quotes and vice versa.

> Quotes enclosed in the @ symbol (before and after) are called HereStrings, and all characters inside them are treated as text. In the code, after '@"' and before '"@' there must be an ENTER.

## Dollar Sign $

* `$` - variables
* `$$` - end of the last executed command, for example `$a="Hello"; $b=$$` results in `$b = "Hello"`
* `$^` - start of the last executed command, for example `$a="Hello"; $b=$^` results in `$b = "$a"`.
* `$_ ($PSItem)` - used to pass a value when using the pipeline (`|`).
* `$?` - stores the status of the last command execution. Returns True if the command was executed successfully and False if there was an error.
* `$()` - used to isolate a subexpression in a string when using double quotes. In this case, the expression in parentheses is processed first.
* `${}` - allows using non-standard characters in a variable name. For example: `${@,&$>?=*} = "Hello, world"`.

## Escape Sequences

PowerShell supports a set of special character sequences that are used to represent characters not included in the standard encoding.

> Sequences are commonly referred to as escape sequences.
>
> Escape sequences start with the backtick character, called a grave accent (ASCII 96), and are case-sensitive.
>
> The backtick character can also be referred to as the escape character.
>
> Escape sequences are processed only in strings contained in double or single quotes.

* `` `0 `` - NULL (not equivalent to $null)
* `` `a `` - Alert
* `` `b `` - Backspace
* `` `e `` - ESC
* `` `f `` - Form feed
* `` `n `` - New line
* `` `r `` - Carriage return
* `` `t `` - Horizontal tab
* `` `u{x} `` - Unicode escape sequence
* `` `v `` - Vertical tab


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sherparpa.ru/en/sherpa-rpa/sherpa-designer/sherpa-designer-otvety-na-chasto-zadavaemye-voprosy/powershell/simvoly-i-operatory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
