我有一個PowerShell腳本(test.ps1)駐留在ServerA上。所有腳本應該做的是檢查服務器上是否存在文件夾。我從一個客戶端執行腳本(同一網絡內)Powershell測試路徑問題:檢查服務器上是否存在文件夾
test.ps1
test-path E:\automation
# returns whether this folder exists on ServerA
我打電話從ComputerB的PowerShell的那個腳本。
PS > pushd \\serverA\scripts
PS > .\test.ps1
輸出:
False
預期輸出:
True
問題:
The script is trying to locate the folder on the "local system" (ComputerB) rather than ServerA
我認爲pushd會這樣做。謝謝。會嘗試。 – DataRiver
Pushd會記住您已移至的路徑。 – Chriseyre2000
所以我們在計算機B上運行Enter-PSSession命令,對嗎? – DataRiver