簡體   English   中英

從另一台計算機運行時,powershell獲取計算機名稱,腳本位於哪里

[英]powershell get computer name where is script located when running from another computer

我有可以從另一台計算機執行的腳本。

如何獲取位置腳本的名稱? 只是名稱,而不是完整路徑(因為腳本可以分布在任何地方),謝謝

我自己解決了。 :-)希望對某人有幫助。

$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
[string[]]$sth = $scriptPath.Split('\',[System.StringSplitOptions]::RemoveEmptyEntries)
$servername = $sth[0]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM