# How to specify installation location

**URL:** <https://forums.powershell.org/t/how-to-specify-installation-location/10567>\
**Category:** PowerShell Help\
**Created:** [April 23, 2018, 8:57am UTC](https://forums.powershell.org/t/how-to-specify-installation-location/10567 "2018-04-23T08:57:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johndav](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@johndav](https://forums.powershell.org/u/johndav)\
**Post date:** [April 23, 2018, 8:57am UTC](https://forums.powershell.org/t/how-to-specify-installation-location/10567/1 "2018-04-23T08:57:26Z")

</div>

I need to deploy an application via PS & SCCM.  
How is the best method of telling PS that the msi is in the same directory as the PS script?  
I can’t hard code the install directory as that will be determined by SCCM.

I read that this is the correct method, however it’ errors out for me.

```
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
```

Error is ‘Split-Path : Cannot bind argument to parameter ‘Path’ because it is null.’

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 23, 2018, 9:16am UTC](https://forums.powershell.org/t/how-to-specify-installation-location/10567/2 "2018-04-23T09:16:10Z")

</div>

In scripts you have the built in automatic variable **$PSScriptRoot** pointing to the directory of the script.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:35pm UTC](https://forums.powershell.org/t/how-to-specify-installation-location/10567/3 "2024-05-16T20:35:09Z")

</div>

Closed on May 16, 2024, 8:35pm UTC


