As a precursor to running an installation file on several remote servers, I need to update the Powershell setting MaxMemoryPerShellMB
. This requires running a PS session as Administrator on the remote server. I have been trying to run Invoke-Command
which then runs a ScriptBlock consisting of a Start-Process
command which includes the -Verb RunAs
parameter. Nothing seems to work, however.
I have tried with various quoting schemes, single, double, triple, but nothing seems to work.
I've tried running the Start-Process
from an Enter-PSSession
, with the same results.
Following is the code I'm testing now:
$creds = Get-Credential -Username 'DOMAIN\userID' -Message "Enter Username and Password to access the remote servers."
$ScriptBlock = {
Start-Process -FilePath Powershell.exe -ArgumentList """Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024""" -Verb RunAs -Wait
}
Invoke-Command -ComputerName testsvr01 -Credential $creds -ScriptBlock $ScriptBlock
I should be able to RDP to the remote server and run Get-Item WSMan:\localhost\Shell
and have it show the updated value, but the value isn't changed.
When running the code it pauses for a second when the Invoke-Command
runs, but other than that, there is no feedback in Powershell.
On the remote server I see the following two Kerberos errors in the System Event log.
0x19 KDC_ERR_PREAUTH_REQUIRED
,
0xd KDC_ERR_BADOPTION
Any help is greatly appreciated.