gpt4 book ai didi

powershell - 在Powershell中执行Enter-PSSession时出现随机错误

转载 作者:行者123 更新时间:2023-12-03 00:52:03 26 4
gpt4 key购买 nike

我在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.

最佳答案

您的远程 session 可能与WS-Man配额MaxMemoryPerShellMB冲突。您可以通过在远程计算机上执行以下命令来查看当前值:

Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 

您可以这样设置一个新值:
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 512 -Force

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

关于powershell - 在Powershell中执行Enter-PSSession时出现随机错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21466960/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com