PowereShell

Hua Wang 1 Reputation point
2021-01-08T17:27:08.967+00:00

I am trying to use PowerShell from my desktop to remote to a sever and run a program there. But the program failed with the error of 'Cannot allocation memory'.

The code I am using is as following

$username = 'myusername'
$password = get-content C:\users\cred.txt
$secureStringPwd = ConvertTo-SecureString $password -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ($username, $secureStringPwd)

Invoke-Command -ComputerName server1 -Credential $creds -ScriptBlock {& 'F:\projects\test.cmd'
}

The program run without any issue if directly run on server1. And the maximum memory used is about 1.7GB. I have expended the MaxMemoryPerShellMB up to 4 GB. But I still got the same error - Can't allocate memory for <..\postal_tables/dph.hsa>. The dph.hsa itself is about 550MB.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. MotoX80 35,596 Reputation points
    2021-01-08T18:30:10.93+00:00

    Can you execute other command line programs from the script, like c:\windows\system32\whoami.exe?

    I am not familiar with the .hsa extension. I do not believe that it is executable. What .exe processes that file? Do you specify the .exe name in test.cmd or do you rely on program associations to open the .hsa file?

    Is that .exe a command line or a GUI program? Does it have any logging command line switches? Or does it log errors to a Windows eventlog?

    Standard question: have you tried rebooting?

    Is it possible that test.cmd is getting an error somewhere, calling itself? That is; test.cmd calls test.cmd over and over until you run out of memory?

    0 comments No comments

  2. Hua Wang 1 Reputation point
    2021-01-08T18:48:39.557+00:00

    I am running a Trillium batch project which is for the data cleanup, USPS address verification, and records matching The dph.hsa is just a USPS postal data file. The .cmd is the project batch which includes call for each .exe package in teh Trillium. My understanding, the USPS package will copy the file into memory and run address verification using this file. The test,cmd does executed and, if I turn off this address verification, everything step in the .cmd batch runs without problem. The command inside the .cmd for this USPS verification is as following
    call "%TS_BIN%\uspmatch" "%TS_SETTINGS%\pmatch_p4.stx" "%TS_LOGS%\pmatch_p4.err"
    the error is logged in tehpmatch_p4.err.

    Thanks for the help.


  3. Hua Wang 1 Reputation point
    2021-01-08T20:01:18.427+00:00

    The exe run a while and stop with that error. I can see it running in the task manager directly on the server. The server is 64-bit windows server2012 R2, but the project (.cmd) is run at 32-bit. This error only happens when I run it remotely by PowerShell. It can run without error if I use the PsTools. Unfortunately, our IT team stopped the using of PsTools due to the security concern and recommended to use PowerShell.


  4. Hua Wang 1 Reputation point
    2021-01-11T15:17:53.693+00:00

    The test.cmd is a batch file that contains sequential steps. Each step has a input and output file The output from the first step will be the input for the second step. They all in the same local folder on the server.

    I tried PSSession, but I cannot make it work. Maybe my account level is not high enough to do this.

    I can use task scheduler on the server to schedule and run the job and there is no problem.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.