https://rakhesh.com/powershell/find-out-if-a-script-was-dot-sourced-or-not/
Find out if a script was dot-sourced or not