0

I have script that is executable from another computer.

How to get comptername of location script? Just name, not full path (because the script can be distributed anywhere) Thanks

1 Answers1

1

Solved on my own. :-) Hope that helps someone.

$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
[string[]]$sth = $scriptPath.Split('\',[System.StringSplitOptions]::RemoveEmptyEntries)
$servername = $sth[0]
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328