2014-10-17 127 views
1

我想使用下面的腳本從不同的森林運行portqry,但我收到路徑無法找到錯誤。而從訪問網絡共享文件我可以手動與無的問題從遠程域訪問從unc路徑Acess exe

#找林名稱

$domain = "spos02600287.test.net" 
$contextType = [system.directoryservices.activedirectory.Directorycontexttype]::Domain 
$domain ="$domain" 
$domainContext = new-object system.directoryservices.ActiveDirectory.DirectoryContext @($contextType,$domain) 
#Query the Forest and PDC Role Emulator 
$Server = [system.DirectoryServices.Activedirectory.Domain]::GetDomain($domaincontext) 
$passwords = "newtemp123" 
$user = "$domain\Administrator" 
$password = $Passwords | ConvertTo-SecureString -AsPlainText -Force 
$creds = New-Object System.Management.Automation.PSCredential -argument $user, $password 

$PDC =$server.Name 
foreach ($serv in $PDC){ 

$Server = "d.root-servers.net" 
$Port = "53" 

Invoke-Command -ComputerName $serv -Credential $creds -ScriptBlock {\\10.28.64.15\EXE\portqry.exe -n $Server -e $Port -p UDP }} 
+0

的問題是由剛剛加入-authentication的CredSSP在調用命令行像下面解決解決Invoke-Command -ComputerName $ serv -Credential $ creds -authentication credssp -ScriptBlock {} – user3130604 2014-10-20 18:17:20

回答

0

遇到什麼樣子著名PowerShell的雙跳的問題。 基本上,通過Invoke-command進行遠程處理時,您無法訪問遠程位置。

另外,你似乎在「-scriptBlock」之後缺少括號?

Here is some more information on the issue.here, from MSDN.

+0

我忘了粘貼括號。我的問題是,如果我做gpupdate而不是訪問腳本塊中的網絡路徑。它工作正常,如果它是雙跳問題,它不應該正常工作? – user3130604 2014-10-17 05:06:13

+0

@ user3130604 gpupdate可以代替「\\ 10.28.64.15 \ EXE \ portqry.exe」,因爲gpupdate是本地的。它不必再次驗證該PC在本地訪問文件。如果您將portqry.exe複製到您正在遠程訪問並在本地訪問的PC,它應該可以正常工作。或者您可以使用鏈接中的信息解決雙跳問題。 – Mokilok 2014-10-18 02:22:23

0

問題是通過剛好在調用命令行中添加-authentication credssp像下面

Invoke-Command -ComputerName $serv -Credential $creds -authentication credssp -ScriptBlock {...}