Wednesday, September 4, 2013

powershell script relative path


Here is the sample code to get the relative path of the powershell script which will help to make consistency when you run script files in multiple environments.

function scriptDirectory()
{
   $path = ""
   $path = [IO.Path]::GetFullPath((join-path $MyInvocation.ScriptName ".\.."))
   return $path
}


The above function will return the script file path as a string value.

No comments:

Post a Comment