远程机器上的调用命令无法使用 powershell [英] invoke command on remote machine is not working using powershell

查看:63
本文介绍了远程机器上的调用命令无法使用 powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Enable-PSRemoting -forceEnter-PSSession Server1invoke-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

<块引用>

这可能与 TrustedHosts 或身份验证有关客户端的设置.你可以这样设置:WinRM setwinrm/config/client @{TrustedHosts="*"}

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

我用

powershell.exe -ExecutionPolicy Unrestricted -WindowStyle Hidden -NoLogo

我使用此代码:

试试{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"退出 0;}抓住{`r`n`r`nError en script de despliegue""`r`nError in " + $_.InvocationInfo.ScriptName + " at line: " + $_.InvocationInfo.ScriptLineNumber + ", offset: " + $_.InvocationInfo.OffsetInLine + ".";退出 -1}

I ran the below commands on my machine to download data from one server to another server using the invoke command

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}

ERROR is: Failed: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

but when i run the above command on my machine as

c:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $true

it works as expected.

Is there something i am missing when i execute it remotely....please help me.

thanks

解决方案

Try this good References:
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="*"}

Read more about this here: http://blogs.dirteam.com/blogs/sanderberkouwer/archive/2008/02/23/remotely-managing-your-server-core-using-winrm-and-winrs.aspx

I use

powershell.exe -ExecutionPolicy Unrestricted -WindowStyle Hidden -NoLogo

I use this code:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆