从https://serverfault.com/questions/752202/install-net-4-6-1-remotely-via-powershell张贴,
基本上我遇到了尝试安装/运行.NET Framework升级的各种错误,因为powershell会话内存不足。试图通过Chocolatey安装,我得到一个'线程无法启动'的问题。尝试通过标准的PowerShell,exe似乎在iex
上“炸弹”,因为提取器占用了太多的内存。我也尝试了Start-Process
和iex("cmd.exe /C pathtoexe.exe")
,但也失败了。
我无法登录所有N个主机并更改其PowerShell限制,如下所示:http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/30/learn-how-to-configure-powershell-memory.aspx因为我拥有大量主机。希望社区有一些想法。下面的脚本
Write-Host "Executing 'Upgrade dotnet 4.6' for $server"
Invoke-Command -ComputerName $servers -Credential $credentials -ScriptBlock {
$Url = 'https://download.microsoft.com/download/E/4/1/E4173890-A24A-4936-9FC9-AF930FE3FA40/NDP461-KB3102436-x86-x64-AllOS-ENU.exe'
$Exe = "net461.exe"
$Dest = "C:\" + $Exe
$Params = " /q"
$client = new-object System.Net.WebClient
$client.DownloadFile($Url,$Dest)
Invoke-Expression ("cmd.exe /C " + $Dest + $Params)
}
答案 0 :(得分:0)
以下Powershell将允许大约150 MB的限制(将其设置为无限制)
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client -Name MaxMemoryPerShellMB -Value 0 -Type DWord
Restart-Service winrm