Cross posted from https://serverfault.com/questions/752202/install-net-4-6-1-remotely-via-powershell,
Basically I am hitting all sorts of errors trying to install/run the .NET Framework upgrade because the powershell session is out of memory. Trying to install via Chocolatey, I get a 'Thread cannot start' issue. Trying via standard powershell, the exe seems to 'bomb out' on iex
because the extractor takes up too much memory. I've also tried Start-Process
and iex("cmd.exe /C pathtoexe.exe")
and that also fails.
I cannot log into all N hosts and change their powershell limit as indicated here: http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/30/learn-how-to-configure-powershell-memory.aspx because I have a LARGE quantity of hosts. Hoping the community has some ideas. Script below
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)
}
The following Powershell will allow getting around the 150 MB limit (setting it to unlimited)
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client -Name MaxMemoryPerShellMB -Value 0 -Type DWord
Restart-Service winrm