PoshCode Archive  Artifact [82df460d03]

Artifact 82df460d0358f097efddd086bbc0b3ed7e0dfbdc85f3b9522e8c48b53a972b9f:

  • File Get-ScriptDirectory.ps1 — part of check-in [343217e918] at 2018-06-10 13:16:33 on branch trunk — Returns the directory that current script is running in. (user: Andy Arismendi size: 610)

# encoding: ascii
# api: powershell
# title: Get-ScriptDirectory
# description: Returns the directory that current script is running in.
# version: 0.1
# type: function
# author: Andy Arismendi
# license: CC0
# function: Get-ScriptDirectory
# x-poshcode-id: 2887
# x-archived: 2015-05-08T16:51:32
# x-published: 2012-08-03T09:02:00
#
#
function Get-ScriptDirectory {   
	$invocation = (Get-Variable MyInvocation -Scope 1).Value
	$script = [IO.FileInfo] $invocation.MyCommand.Path
	if ([IO.File]::Exists($script)) {
    	Return (Split-Path $script.Fullname)
	} else {
		return $null
	}
}