我用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 commandEnable-PSRemoting -forceEnter-PSSession Server1invoke-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 asc:\temp.ps1 -server serverX -id 4231e429-d238-4e32-a1bb-0ee812cd3124 -download $trueit 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=1108http://technet.microsoft.com/en-us/magazine/ff700227.aspx Read more about this here:http://blogs.dirteam.com/blogs/sanderberkouwer/archive/2008/02/23/remotely-managing-your-server-core-using-winrm-and-winrs.aspxI usepowershell.exe -ExecutionPolicy Unrestricted -WindowStyle Hidden -NoLogoI 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 17:27