If you open 2 separate consoles, you need to add some logic to your script to make some changes to the file system, registry, or even the title bar of the PowerShell session where it is running.Then you can use some logic on your second console to find this information .
Another way that I usually use is WMI:
PS>get-wmiobject win32_process|where {$_.name -eq "powershell.exe"}|select-exp commandline
Example:
CommandLine : powershell.exe -file "./loop.ps1"
This means that you need to call powershell.exe to run the script.
source share