powershell - 远程机器上的调用命令无法使用 powershell

标签 powershell

我在我的机器上运行以下命令,使用 invoke 命令将数据从一台服务器下载到另一台服务器

Enable-PSRemoting -force 

Enter-PSSession Server1

invoke-command -computername Server1 -credential:'dom\jack' {c:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $true}

错误是:失败:访问被拒绝。 (来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))

但是当我在我的机器上运行上述命令时
c:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $true
它按预期工作。

当我远程执行它时,我是否遗漏了什么......请帮助我。

谢谢

最佳答案

试试这个很好的引用资料:
http://www.ravichaganti.com/blog/?p=1108
http://technet.microsoft.com/en-us/magazine/ff700227.aspx

It might be something to do with the TrustedHosts or Authentication setting of a client. You can set it like this:WinRM set winrm/config/client @{TrustedHosts="*"}



在此处阅读更多相关信息:
http://blogs.dirteam.com/blogs/sanderberkouwer/archive/2008/02/23/remotely-managing-your-server-core-using-winrm-and-winrs.aspx

我用
powershell.exe -ExecutionPolicy Unrestricted -WindowStyle Hidden -NoLogo

我使用这个代码:
try
{

    Invoke-Command -credential $testCred -computer $ServerName -scriptblock { 
        param([String]$scriptDeploy, [String]$destino)  &"$scriptDeploy" 'parametro1' $destino
        $ScriptBlockOutput = $Error
    } -ArgumentList $RutaRemotaParaScriptDeInstalacion, "$dirRemotoDestino" 

    "`r`n`r`nOK para script de despliegue"
    exit 0;

}
catch
{
    "`r`n`r`nError en script de despliegue"
    "`r`nError in " + $_.InvocationInfo.ScriptName + " at line: " + $_.InvocationInfo.ScriptLineNumber + ", offset: " + $_.InvocationInfo.OffsetInLine + ".";

    exit -1
}

关于powershell - 远程机器上的调用命令无法使用 powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7508137/

相关文章:

python - VS Code 启动命令行参数来更改扩展参数

string - 在大文件中高效地搜索字符串

powershell - 是否有任何 New-WebServiceProxy 替代方案?

sharepoint - 如何从 powershell 发布/批准 SharePoint 2010 中的页面

regex - 在 powershell 中按正则表达式内的命名捕获组排序

PowerShell - 用于处理 cmdlet 的动词是什么?

powershell - 比较对象 : PassThru parameter alters input variable

powershell - 使用 PowerShell 更新计划任务

windows - 排序对象对 Get-EventLog 没有影响

powershell - 在 Powershell 中,是否有比自定义对象更好的方法来存储/查找 n 维数组中的数据