Working with Variables
Свайпніть щоб показати меню
1234# Defining and assigning values to variables in PowerShell $greeting = "Hello, PowerShell!" $number = 42 $isEnabled = $true
Variables in PowerShell allow you to store and reuse data throughout your scripts. When naming variables, follow these rules:
- Start the name with a dollar sign (
$); - The first character after
$must be a letter or underscore; - Use only letters, numbers, and underscores in the name;
- Avoid spaces and special characters;
- Variable names are not case-sensitive.
Variable scope determines where a variable can be accessed. Most variables you create are local to your script or session, but you can specify other scopes like
global:orscript:if required.
1234# Variable interpolation in PowerShell strings $name = "Sam" $message = "Welcome, $name!" Write-Output $message # Output: Welcome, Sam!
1. Which of the following is a valid variable name in PowerShell?
2. What is variable interpolation in PowerShell strings?
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 1. Розділ 3
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Секція 1. Розділ 3