install from any location

hi all. currently i have a script that is coded to run from the desktop, i would like to change it to run form anywhere.it has files it calls on that is located in a sub folder in the same parent folder
.\script\ de.ps1 (main script)
.\script\bin\test.* (file it calls)

this is what i have so far. but it not locating the Test.*

Function get-location
{
$invocation = (get-variable myinvocation -scope 1).value
split-path $invocation.mycommand.path
}
$dir = get-location
copy-item $dir\bin\test.* 'c:program files\'

thanks for any help

Your $invocation.mycommand.path is not returning what you want.

Try one of these based on your need:

-------------------------------------------
For PS 2.0: $MyInvocation.MyCommand.Definition
C:\temp\test.ps1

For PS 2.0: Split-Path -parent $MyInvocation.MyCommand.Definition
C:\temp

For PS 3.0 and later: $PSCommandPath
C:\temp\test.ps1

For PS 3.0 and later: Split-Path -parent $PSCommandPath
C:\temp

For PS 3.0 and later: $PSScriptRoot
C:\temp
-------------------------------------------