Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有可以从另一台计算机执行的脚本。
如何获取位置脚本的comptername?只是名称,而不是完整路径(因为脚本可以分发到任何地方)谢谢
我自己解决了。:-) 希望对某人有所帮助。
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition [string[]]$sth = $scriptPath.Split('\',[System.StringSplitOptions]::RemoveEmptyEntries) $servername = $sth[0]