我打算使用下面的脚本从不同的林中运行portqry,但是我接收到的路径是错误的。当我从网络共享访问文件时,我可以手动访问它,不会出现来自远程域的问题。
获取森林名称
$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 }}发布于 2014-10-17 00:40:52
您正在经历的事情看起来就像著名的PowerShell双跳问题。基本上,当通过调用命令进行远程处理时,您无法访问远程位置。
另外,你似乎在"-scriptBlock“之后没有括号?
以下是有关这一问题的更多信息。和这里,来自MSDN。
发布于 2014-10-20 18:18:41
通过在invoke命令行中添加-authentication credssp解决了这个问题,如下所示
Invoke-Command -ComputerName $serv -Credential $creds -authentication credssp -ScriptBlock {...}https://stackoverflow.com/questions/26415996
复制相似问题