Zombie
Zombie

Reputation: 23

Powershell variable Path

I'm sorry if that question already got asked but I didn't find anything around here so here I go:

So I wrote a little PowerShell Script to ease the work for our IT Colleagues (Ping IPs/Computernames, open the Log files of the User, start a remote job of the computer etc.)

To start a remote job on given IP / Computername, I used this:

C:\Users\user\Desktop\Toolv1\RemoteControlViewer_SCCM2012\CmRcViewer.exe $objTextBox.Text

This works fine on my Computer at the moment, but how do I insert a variable Path that uses the current Path + *\RemoteControlViewer_SCCM2012\CmRcViewer.exe $objTextBox.Text so I can share my Script with my colleagues without changing the Path each time in the script?

I already tried things like:

($PSScriptRoot + \RemoteControlViewer_SCCM2012\CmRcViewer.exe) $objTextBox.Text

But I guess I'm doing something wrong.

Any tips?

Upvotes: 1

Views: 289

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174485

Use Join-Path to construct the full path, then & to invoke the executable:

& (Join-Path $PSScriptRoot RemoteControlViewer_SCCM2012\CmRcViewer.exe) $objTextBox.Text

Upvotes: 2

Related Questions