Reputation: 31
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
Upvotes: 0
Views: 315
Reputation: 31
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]
Upvotes: 1