【问题标题】:Random errors while doing Enter-PSSession in powershell在 powershell 中执行 Enter-PSSession 时出现随机错误
【发布时间】:2014-02-23 08:58:24
【问题描述】:

我在我的 WIndows 2008 R2 服务器上设置了很多 Powershell 脚本。脚本进行大量处理(数据处理、执行 SQLCMD.exe、bcp.exe 等)。所有这些脚本都可以正常工作。

我正在尝试使用以下命令从远程笔记本电脑(在同一网络内)调用和执行脚本:

Enter-PSSession -ComputerName sun -ConfigurationName myprofile

“myprofile”目前只有一个函数可以将目录更改为 c:

这允许我从本地笔记本电脑执行脚本,但是,它们在服务器上“运行”。这是我的理解。

但是,我还没有看到任何脚本完全执行。每隔一段时间,脚本就会失败,并显示以下错误消息……再一次,当我尝试在服务器本身上运行脚本时,我从未见过这些错误。

关于如何“修复”这些错误的任何意见?在内存分配方面,我需要在“客户端”上进行任何设置吗?

一个。

Processing data for a remote command failed with the following error message: Not enough storage is available to complete this operation. For more information, see the about_Remote_Troubleshooting Help topic.

b.

Get-Content : Exception of type 'System.OutOfMemoryException' was thrown.
At E:\automation\mssql-upload.ps1:144 char:14
+     (get-content <<<<  $PipeFile -ReadCount 1000) | set-content $FinalFile
+ CategoryInfo          : InvalidOperation: (:) [Get-Content], OutOfMemoryException
+ FullyQualifiedErrorId : ProviderContentReadError,Microsoft.PowerShell.Commands.GetContentCommand

c.

[Microsoft] [ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV

d.

Processing data for a remote command failed with the following error message: The WSMan provider host process did not return a proper response.  A provider in the host process may have behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic.

【问题讨论】:

  • 远程计算机为每个远程会话配置了多少内存?在远程计算机Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 上运行此命令进行检查。如果值看起来很小,您可以使用Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB &lt;number&gt; -Force 进行更改
  • 我似乎遇到了错误:Get-Item : Cannot find path 'WSMan:\localhost\Shell\MaxMemoryPerShellMB' because it does not exist.
  • 如果有帮助:Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1
  • 想通了。需要以管理员身份运行。其设置为 150 MB。推荐值应该是多少?
  • 让我试试看是否有帮助...

标签: powershell scripting powershell-remoting


【解决方案1】:

您的远程会话很可能会超出 WS-Man 配额 MaxMemoryPerShellMB。您可以通过在远程机器上执行此命令来查看当前值:

Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 

你可以像这样设置一个新值:

Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 512 -Force

这会将值设置为 512MB。将其设置为适用于您的应用程序的值。

【讨论】:

  • 你能开多大,我目前设置为3096还是报这个错误
猜你喜欢
  • 2019-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-26
  • 1970-01-01
  • 2011-04-11
  • 2021-04-14
相关资源
最近更新 更多