Dec 21 2022 07:04 AM - edited Dec 21 2022 07:10 AM
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 $ScriptFolderPath ).parent.FullName
$ScriptName = $MyInvocation.MyCommand.Name
$ScriptNameNoExtension = [System.IO.Path]::GetFileNameWithoutExtension($MyInvocation.MyCommand.Source)
Is there a clean, durable and standardized way of getting all these values (working in PS5 and 7) ?
Thank you.
Dec 23 2022 07:36 AM
Jan 24 2023 12:11 PM
Sorry for the late answer.
I think my question was not clear enough.
Basically I need to set these variables because I want to use them in my scripts (so transcript isn't an option). But as you can see in my code I am using different ways to get the said values.
My question was, is there any standardize way to all the values? (Using the same logic for all of them). Still not clear maybe...
Jan 24 2023 12:33 PM
Jan 24 2023 12:52 PM
Jan 24 2023 01:14 PM
Jan 24 2023 01:30 PM
Jan 24 2023 01:45 PM