What is the best way to study the script using debugger vscode

creative555
creative555 used Ask the Experts™
on
Hello,
I need to study the following script. What it does and understand it.

SO I am using debug mode in Vscode, but when I click on “Step into”, it is skipping and not going into the next line. Perhaps something is wrong with my VScode?

What is the best way for me to study the script and see what it does? How to manually paste the blocks and study?

So I set the debugger on line 1
When I click the down error Step into, it jumps into the line 206.

For example, I need to understand what does this do? How would I accomplish this with the debugger or manual process. tried copying and pasting and still doesn't understand what it tries to do
gc $sidMappingsFile | foreach {

            $orgShell = $null
            $fields = "","",""
            $fields = $_.ToString().Split(",")

            if ($fields[2] -eq "True") {
                $sourcesid = $fields[0]
                $targetSid = $fields[1]
                $isprimary = $fields[2]
         

Thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
As you have posted only a fragment of code, it is difficult to be specific with why things happen.

From what we see, the behaviour is correct - you step into something which does not have anything to process. The variable $sidMappingsFile is not set, and so the get-childitem probably finds no file (depending on the current working directory).

For debugging you should have at least a basic understanding of how PowerShell and the common cmdlets work. It does not make sense to just copy arbitrary fragments without the context. And you should definitely start with something more simple than >200 lines of code ...

Author

Commented:
thank you very much! good suggestions!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial