Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to override powershell memory limit in remote session

$
0
0

Hi,

I am trying to run a memory allocation tool (testlimit64 from sysinternals suite) on multiple windows VMs remotely. The VMs run windows server 2012, patched up to date.

The machine i'm running the code from also runs windows server 2012.

The code I use to run the testlimit commands is this:

#run memory load routine
foreach ($vm in $testvmsview) {    $vm.IP    
   $s = new-pssession  -ComputerName $vm.IP -credential $cred    Invoke-Command -Session $s -FilePath "C:\Scripts\LoadMem.ps1" -ArgumentList '80'    Read-Host "Enter to continue"    }


The "C:\Scripts\LoadMem.ps1" file that gets executed on the other side is this:

param( [Parameter(Mandatory=$false)][System.String]$PercentAvailRAM=50)

$OBjectCount = [math]::Round(($PercentAvailRAM/100) * (((Get-WMIObject Win32_OperatingSystem).FreePhysicalMemory)/1KB))

#$OBjectCount

$loadmemcmd = "c:\temp\testlimit64.exe -d -c $OBjectCount"

Invoke-Expression $loadmemcmd

The code runs fine, but testlimit returns this error:

Testlimit v5.22 - test Windows limits
Copyright (C) 2012 Mark Russinovich 
Sysinternals - www.sysinternals.com

Process ID: 3152

Leaking private bytes with touch (MB)...

99
199
299
399
499
599
699
799
The paging file is too small for this operation to complete.
    + CategoryInfo          : NotSpecified: (The paging file...on to complete.:String) [], RemoteException+ FullyQualifiedErrorId : NativeCommandError+ PSComputerName        : pc.contoso.com

The issue I am seeing is that, when i run the script remotely, the testlimit64 process is limited to almost 1GB of RAM. I also ran the piece of code in a powershell window, while connected via RDP, and the testlimit64 command works fine, i get the correct amount of ram assigned to the process.

I have tried to change the MaxMemoryPerShellMB value to other values (i suspected it was because of this). i change to 5000MB, 192000MB, no diference in the way my code runs. INvoke-command remotely limits to 1GB, local console runs up to whatever memory allocation I need

Does anyone know why this is happening?

Thank you,
Ionut



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>