There are several ways:

Write-Host: Write directly to the console, not included in function/cmdlet output. Allows foreground and background colour to be set.

Write-Debug: Write directly to the console, if $DebugPreference set to Continue or Stop.

Write-Verbose: Write directly to the console, if $VerbosePreference set to Continue or Stop.

The latter is intended for extra optional information, Write-Debug for debugging (so would seem to fit in this case).

Additional: In PSH2 (at least) scripts using cmdlet binding will automatically get the -Verbose and -Debug switch parameters, locally enabling Write-Verbose and Write-Debug (i.e. overriding the preference variables) as compiled cmdlets and providers do.

Answer from Richard on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.utility › get-variable
Get-Variable (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
The Get-Variable cmdlet gets the PowerShell variables in the current console. You can retrieve just the values of the variables by specifying the ValueOnly parameter, and you can filter the variables returned by name.
Discussions

Echo equivalent in PowerShell for script testing - Stack Overflow
Doesn't show actual values processed (e.g. env var substitution) so not an answer to the question asked. 2019-08-26T21:23:16.033Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 5 The word "encode" in a Wscript.Shell Exec does prevent powershell script from running. What can I do? 4 Gitlab-CI: set different variables... More on stackoverflow.com
🌐 stackoverflow.com
Outputting variable value
Hi everyone, I am new to PowerShell so apologies if I don’t explain this clearly. I have a file that contains a list of directories/folders in a CSV. I want to loop over each of those file paths and return the users who have access to that file directory/folders. More on forums.powershell.org
🌐 forums.powershell.org
4
0
October 3, 2022
Variables for Input(s) and output
Hello, Pretty new to powershell, (at least on the learning how to script front) and have recently started to dig in and figure out how to do everything. I have some good scripts from a previous co-worker, and after 24 hours of Powershell youtube videos, I can understand everything they do now! More on forums.powershell.org
🌐 forums.powershell.org
0
0
February 19, 2022
how to see value of a variable in powershell - Stack Overflow
I am setting a variable but I can't get the value back. More on stackoverflow.com
🌐 stackoverflow.com
🌐
EITCA Academy
eitca.org › home › how can you output the value stored in a variable in powershell?
How can you output the value stored in a variable in PowerShell? - EITCA Academy
August 5, 2023 - In this syntax, `$VariableName` represents the name of the variable that contains the value you want to output. For example, if you have a variable named `$UserName` that stores a user's name, you can display it using the Write-Output cmdlet like this: powershell $UserName = "John Doe" Write-Output -InputObject $UserName
🌐
PDQ
pdq.com › powershell › get-variable
Get-Variable - PowerShell Command | PDQ
You can retrieve just the values of the variables by specifying the ValueOnly parameter, and you can filter the variables returned by name. ... Specifies an array of items that this cmdlet excludes from the operation. Wildcards are permitted. ... Specifies an array of items upon which the cmdlet ...
🌐
Codecademy
codecademy.com › docs › powershell › variables
PowerShell | Variables | Codecademy
June 8, 2023 - Variables in PowerShell are referenced using a dollar sign $ followed by a valid variable name. ... To create a variable, a variable reference is followed by an equal sign = and the value to be assigned.
Find elsewhere
🌐
PowerShell Forums
forums.powershell.org › powershell help
Variables for Input(s) and output - PowerShell Help - PowerShell Forums
February 19, 2022 - Hello, Pretty new to powershell, (at least on the learning how to script front) and have recently started to dig in and figure out how to do everything. I have some good scripts from a previous co-worker, and after 24 …
🌐
SS64
ss64.com › ps › get-variable.html
Get-Variable - PowerShell cmdlet
Get PowerShell variables in the current console. Syntax Get-Variable [[-Name] String[] ] [-Include string] [-Exclude string] [-valueOnly] [-scope string] [CommonParameters] Key -Name The name of the variable(s), may be piped. -include string Retrieve only the specified items.
🌐
4sysops
4sysops.com › home › blog › articles › display and search all variables of a powershell script with get-variable
Display and search all variables of a PowerShell script with Get-Variable – 4sysops
July 28, 2023 - The Get-Variable cmdlet allows you to display the values of all variables in your current console. However, if you want to use the cmdlet to debug your scripts, you face two problems.
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.core › about › about_variables
about_Variables - PowerShell | Microsoft Learn
You don't have to declare the variable before using it. The default value of all variables is $null. To get a list of all the variables in your PowerShell session, type Get-Variable.
🌐
ShellGeek
shellgeek.com › home › powershell › powershell get variables
PowerShell Get Variables - ShellGeek
April 14, 2024 - PS C:\> Get-Variable t*, m* Name ...t.Automation.InvocationInfo · To get variables in PowerShell by scope, use the Get-Variable -Scope parameter....
🌐
GitHub
github.com › PowerShell › vscode-powershell › issues › 1204
Wish: Is there a way to show Variables when executing line (F5) or block (F8) · Issue #1204 · PowerShell/vscode-powershell
February 21, 2018 - After writing I mark the line and execute it via F5, so the variable is filled. If I want to see how its filled I have to mark it and press again F5.
Author   logg-sar
🌐
Netwrix
netwrix.com › en › resources › blog › powershell-environment-variables
PowerShell Environment Variables
August 25, 2025 - PowerShell environment variables store system and user configuration as key-value pairs accessible across processes and scripts. They can be listed with Get-ChildItem Env:, accessed with $Env: , modified with Set-Item or [Environment]::SetE...
🌐
TestMu AI Community
community.testmuai.com › ask a question
How can I display variables and their values in a PowerShell script, similar to using echo in PHP? - TestMu AI Community
August 31, 2024 - How to Output Variables and Values in a PowerShell Script? I would like to output variables and values in a PowerShell script by setting up flags and seeing the data matriculate throughout the script. How would I do thi…
🌐
LazyAdmin
lazyadmin.nl › home › how to use powershell variables
How to use PowerShell Variables — LazyAdmin
January 18, 2024 - If you only want to view the value of a variable, then use the -ValueOnly parameter. Variables are the bread and butter of every programming or scripting language, including PowerShell.
🌐
PowerShell Test-Path
powershellfaqs.com › powershell-print-variable
PowerShell Print Variable [With Examples]
February 14, 2025 - You can also embed variables directly within strings in PowerShell. $city = "San Diego" Write-Output "Welcome to $city!" This will print “Welcome to San Diego!”. Sometimes, you may need to save the output to a file rather than displaying it on the console. $city = "Dallas" $path = "C:\USA_Cities.txt" Add-Content -Path $path -Value $city · This will append “Dallas” to the file located at C:\USA_Cities.txt. Now, let me show ...
🌐
PowerShell Test-Path
powershellfaqs.com › output-variables-in-powershell
Output Variables in PowerShell
September 12, 2024 - The Write-Output cmdlet is the most common way to display the value of a variable in PowerShell. It writes the variable’s value to the output stream, which can be displayed in the console or passed to another cmdlet. ... In this example, the Get-Process cmdlet retrieves information about ...