Newbie question 2:I want to determine the containing folder and name of the script being executed from within the script. how do I do the equivalent of these lines of VBScript code?==========We are working with two object, the FileSystemObject, and the Shell object. I have created them here.thisDir = objFSO.GetFolder( objFSO.GetParentFolderName( WScript.ScriptFullName ) ) & ""This
line (there should be no line break) retrieves the name of the folder
that you've keeping the backup files in. We could have simply coded in
Find path and name of script from script?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- alec_burgess
- Posts: 4
- Last visit: Thu Sep 04, 2008 4:18 pm
Find path and name of script from script?
To return the script name:
$thisScript = Split-Path $myInvocation.MyCommand.Path -Leaf
To return the parent folder of the script
$scriptRoot = Split-Path (Resolve-Path $myInvocation.MyCommand.Path)
$thisScript = Split-Path $myInvocation.MyCommand.Path -Leaf
To return the parent folder of the script
$scriptRoot = Split-Path (Resolve-Path $myInvocation.MyCommand.Path)