This has been tested on Windows 10 – will not work on a Server OS:

$networkRegistry='REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters'
$keyName='IRPStackSize'
$keyValue=32
$previousValue=(Get-ItemProperty -Path $networkRegistry -Name $keyName).$keyName
if($keyValue -ne $previousValue){
    set-itemproperty -path $networkRegistry -Name $keyName -Value $keyValue
    $setValue=(Get-ItemProperty -Path $networkRegistry -Name $keyName).$keyName
    write-host "$keyName previous value $previousValue has been changed to $setValue"
}else{
    write-host "$keyName current value of $previousValue is already matching the intended set value."
}