标签: powershell-remoting

令人困惑的Powershell行为

有点困惑w /远程执行powershell命令.我有一个名为ServerA的测试服务器(Win 2k8-R2-SP1),它正确启用了PowerShell远程处理.从我的开发机器(Win 2k8-R2-SP1),我能够正确远程执行powershell命令.但是,当我尝试从名为ServerB(Win 2k8-R2)的不同服务器执行相同的命令时,我收到以下错误

[ServerA] Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: …

powershell powershell-remoting

21
推荐指数
2
解决办法
5万
查看次数

如何托管Powershell脚本或应用程序,以便可以通过WSManConnectionInfo访问它?(如Office 365)

我知道连接到远程运行空间的唯一方法包括以下参数

   WSManConnectionInfo connectionInfo = 
     new WSManConnectionInfo(false, "localhost", 80, "/Powershell", "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
Run Code Online (Sandbox Code Playgroud)

要么

   WSManConnectionInfo connectionInfo = 
     new WSManConnectionInfo(false, "localhost", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.Powershell", credential);
Run Code Online (Sandbox Code Playgroud)
  • 如何设置我自己的自定义Powershell对象,以便通过HTTP公开它?

  • 使用的正确参数是什么以及如何设置它们?

c# powershell cmdlets powershell-remoting runspace

19
推荐指数
1
解决办法
2867
查看次数

Enter-PSSession到远程服务器失败,"找不到计算机"

我的桌面是win7,我正在尝试连接到服务器2012.
两个主机都在同一个域上.

如果我做:

Enter-PSSession -ComputerName *ServerName***   
Run Code Online (Sandbox Code Playgroud)

我从winrm收到以下失败消息

Enter-PSSession:连接到远程服务器xxx失败,并显示以下错误消息:WinRM无法处理请求.使用Kerberos身份验证时发生以下错误:找不到计算机xxx.验证网络上是否存在计算机,并且提供的名称拼写正确.*

如果我只使用服务器名称或完全符合条件输入它并不重要.

两个系统都表明了 $PSVersionTable.PSVersion 4 0 -1 -1

我已经尝试了各种故障排除提示,我发现即
运行Enable-PSRemoting -Force,也设置TrustedHosts = *在两侧.
我还禁用了双方的防火墙服务.
当我尝试从服务器将Enter-PSSession输入到我的桌面时,它可以根据需要运行.
但是从我的桌面到服务器,我总是收到无法找到计算机的错误消息.

powershell-remoting powershell-3.0

18
推荐指数
2
解决办法
3万
查看次数

在Powershell中运行远程GUI应用程序

我们有一个自定义组件,它包含了PowerShell的一些功能,因此可以在BizTalk 2006中使用它.对于大多数操作(检查文件路径,复制或移动文件),这样可以正常工作.但是,我们需要远程启动GUI应用程序以进行一些处理.组件本身处理与远程盒的连接,我们所要做的就是设置一些参数然后告诉它执行一个命令

Start-Process -FilePath "path to exe" -ArgumentList "arguments for exe" -WorkingDirectory "workingdir for exe"
Run Code Online (Sandbox Code Playgroud)

问题是:如果我们从盒子本身的powershell命令行运行它,这很好.然而,当我们远程启动它时(从BizTalk,从测试工具,甚至使用远程Powershell命令行和通过Start-PSSession连接),此应用程序将短暂运行然后退出而不实际执行任何操作.我怀疑是因为有问题的exe需要加载GUI才能运行该进程,这就是导致问题的原因.我已经尝试了我能想到的一切,包括-NoNewWindow和-WindowStyle,但无济于事.任何帮助实现这项工作将非常感激.

注意:我们无法访问我们尝试运行的应用程序的源代码,因为它是较旧的win32应用程序,并且未提供此应用程序的批处理或命令行版本.

powershell powershell-remoting

17
推荐指数
2
解决办法
2万
查看次数

停止Powershell退出

我知道-noexitPowerShell 有一点开关.

无论如何都没有使用那个开关而留在shell中?

换句话说,我想要一个执行的脚本命令然后打开shell.

powershell powershell-2.0 powershell-remoting

17
推荐指数
4
解决办法
10万
查看次数

如何从Invoke-Command写入详细信息?

在powershell中

Write-Verbose并且该-Verbose标志用于在详细模式下运行命令时提供详细信息.我正在远程运行一些脚本,并希望捕获详细的输出输出.但是,Invoke-Command似乎没有捕捉到冗长的频道.

PS:> Invoke-Command -ComputerName MY-COMPUTERNAME -Verbose { Write-Verbose "blah" }
PS:>
Run Code Online (Sandbox Code Playgroud)

如何在运行远程脚本时捕获详细输出?

powershell powershell-remoting

16
推荐指数
2
解决办法
6733
查看次数

Powershell - 查找调用脚本的用户

我有一个脚本(我们称之为myPSScript.ps1),它采用两个参数并执行预定义的步骤.脚本位于Windows Server框中,人们登录并执行脚本.支持两个用户在给定时间登录.

我想找出谁调用了脚本.

(Get-WmiObject -Class Win32_Process | Where-Object {$_.ProcessName -eq 'explorer.exe'}).GetOwner() | Format-Table Domain, User 
Run Code Online (Sandbox Code Playgroud)

当用户当前登录并尝试运行脚本时,此方法有效.但是如果我在计划任务中有一个批处理文件并运行相同的脚本呢?

在这种情况下,同一个命令返回一个空异常,因为没有人登录到该机器.

有没有办法找出谁/哪个进程调用了powershell脚本.我依稀记得Start-Transcript记录从哪个用户运行命令,所以这应该是可能的?

谢谢!Sanjeev

powershell powershell-2.0 powershell-remoting

15
推荐指数
1
解决办法
2万
查看次数

Powershell Remoting:在远程pssession中使用导入的模块cmdlet

有没有办法使用在远程会话中的本地会话中导入的模块?我查看了import-pssession,但我不知道如何获得本地会话.这是我想要做的样本.

import-module .\MyModule\MyModule.ps1
$session = new-pssession -computerName RemoteComputer
invoke-command -session $session -scriptblock { Use-CmdletFromMyModule }
Run Code Online (Sandbox Code Playgroud)

另外,我不想在远程会话中导入模块,因为ps1文件不在该服务器上.

powershell powershell-remoting powershell-module

14
推荐指数
2
解决办法
2万
查看次数

WinRM无法处理请求 - 仅在特定域上失败

我们的一些服务器(W2K8 R2)上周被移动到云端,一旦我的powerswhell脚本开始失败(之前工作正常),在尝试建立连接的行上抛出异常,

$ExSession = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri     "http://$g_strExchangeServer/PowerShell" `
-Credential $Credentials –Authentication Kerberos
Run Code Online (Sandbox Code Playgroud)

通过以下消息,

[subd.staging.com] Connecting to remote server failed with the following error message : 
**WinRM cannot process the request**. The following error occured while using Kerberos authentication: There are currently no logon servers available to service the logon request.  
Possible causes are:
-The user name or password specified are invalid.
-Kerberos is used when no authentication method and no user name are specified.
-Kerberos accepts domain user …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-2.0 powershell-remoting winrm

13
推荐指数
1
解决办法
6万
查看次数

发布管理vNext组件部署瓶颈

我们将Release Management 2015与vNext发布模板一起使用.我们为应用程序的每个部分都提供了基于Powershell DSC的组件部署,事实上,我们正在部署两个不同的应用程序,这些应用程序处于活动开发阶段,并且通常几乎同时部署.

我们经常在部署期间收到以下错误:

OperationFailedException:不允许进行新部署,因为另一个部署正在进行中.有一段时间后重试部署.

完整的堆栈跟踪显示错误不是来自Powershell本身,而是来自负责在目标机器上执行powershell脚本的Release Management系统:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.TeamFoundation.Release.Common.Helpers.OperationFailedException: New deployment is not allowed as an another deployment is in progress. Retry the deployment after sometime.
   at Microsoft.TeamFoundation.Release.EnvironmentProvider.OnPrem.Implementation.OnPremDeploymentProvider.ReadDeploymentResponse(DeploymentResponse response)
   at Microsoft.TeamFoundation.Release.EnvironmentProvider.OnPrem.Implementation.OnPremDeploymentProvider.RunScript(String scriptPath, String configurationPath, MachineSpecification machine, StorageSpecification storage, Dictionary`2 configurationVariables)
   at Microsoft.TeamFoundation.Release.MonitorServices.Dsc.OnPrem.OnPremDeploymentActions.InvokePlatform(String activityId, MachineSpecification machineSpecification, StorageSpecification storageSpecification, String scriptPath, String configurationPath, Dictionary`2 configurationVariables)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-remoting ms-release-management

13
推荐指数
2
解决办法
795
查看次数