Forum Discussion
John_Dodo
Dec 21, 2022Copper Contributor
Retrieve executed script information the best way
Hello, I have this piece of code at the begining of most of my script. $ScriptFolderPath = $PSSCRIPTROOT
$ScriptFolderName = (get-item $ScriptFolderPath ).Name
$BaseFolder = (get-item $Sc...
John_Dodo
Jan 24, 2023Copper Contributor
Template script if you will yes.
The section of code I have written in my first message is at the beginning of all my main scripts.
I just want to know what is best to retrieve these values. Using $PSSCRIPTROOT method, using $myinvocation or something else.
The section of code I have written in my first message is at the beginning of all my main scripts.
I just want to know what is best to retrieve these values. Using $PSSCRIPTROOT method, using $myinvocation or something else.
Jan 24, 2023
For the PowerShell_ISE editor, you could create snippets like this https://learn.microsoft.com/en-us/powershell/module/ise/new-isesnippet?view=powershell-5.1 . Import them in your script when running ISE by using CTRL-J. In VSCode it's a bit different, https://code.visualstudio.com/docs/editor/userdefinedsnippets