When developing code/debugging and running just a section, the built in Get-ScriptDirectory throws an error as the the values it is looking for do not exist, this will return the current working directory that the PowerShell Session Console is in.
Code: Select all
#Sample function that provides the location of the script
Get-ScriptDirectory returns the proper location of the script.
Returns the correct path within a packaged executable.
if ($hostinvocation -ne $null)
elseif ($script:MyInvocation.MyCommand.Path -ne $null)