3

In bash you can use set -x which will print the executed command line. If, for example, you have the following bash script:

#!/bin/bash

set -x

echo "Hello world!"

The output will be

+ echo "Hello world!"
Hello world

The first line contains + which indicates the executed command and everything afterwards is the output of the command.

Is there something similar in powershell that would print out the executed command?

=== script 

$myVar = C:\
ls $myVar

=== output

+ ls C:\
....
02/14/2023  09:19 PM    <DIR>          Windows
               1 File(s)            681 bytes
              18 Dir(s)  514,576,928,768 bytes free

tftd
  • 16,203
  • 11
  • 62
  • 106

0 Answers0