Don't have access to object after script ends

I write some script in Visual Studio Code. After I run it and after it ends its job I have access to object generated by this script. I need access to it for further, manual, analyse.

But when I run this script from Windows Terminal with PS 7.1 or from Windows Powershell 5.1 I don’t have access to this object… it is empty.
I tried with setting scope for this object to global ($global:object_name), but this don’t help.

What should I do to have access to object generated by script, after it ends its work?

Best Regards

How do you run this script? Did you try to “dot source” it?

From VSC I run it by F5 and from Windows Terminal or PowerShell 5.1 I type .\script.ps1 and hit enter.

Try to “dot source” it! Instead of


You do

. .\script.ps1

!! Please notice the dot and the space in front of the script path !!

It works !:slight_smile:
But, to be honest, this is new information for me.
Thank you :slight_smile:

You may read more about that topic …