Com +对象更改PowerShell的内存限制

时间:2017-06-07 17:56:58

标签: powershell com+

如何使用PowerShell更改com +对象的内存限制?

在这里,我使用gui将内存限制增加到1GB。

enter image description here

1 个答案:

答案 0 :(得分:0)

Microsoft有一个关于如何使用visual basic

执行此操作的文档

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684192(v=vs.85).aspx

以下powershell将增加内存限制。您需要将$ AppID和$ CLSID更改为相应的标识符

$AppID = "{11111111-1111-1111-1111-111111111111}"
$CLSID = "{22222222-2222-2222-2222-222222222222}"
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog


function ConfigurePoolLimits ( $comAdmin , $MemoryLimit) {
    Write-Host "Configuring Pool Limits"

    $apps = $comAdmin.GetCollection("Applications")
    $apps.Populate();
    $changesMade = $false
    foreach ($app in $apps ) {
        if ($app.Name -eq $AppName ) {
            Write-Host "Found Application $($app.Name)"
            Write-Host "RecycleMemoryLimit is $($app.Value("RecycleMemoryLimit"))"
            if ($app.Value("RecycleMemoryLimit") -ne $MemoryLimit) {
                $changesMade = $true
                Write-Host "Changing RecycleMemoryLimit to $($MemoryLimit)"
                $app.Value("RecycleMemoryLimit") = $MemoryLimit
            }
        }
    }
    if ($changesMade) {
        $apps.SaveChanges();
    }
}

然后用2个参数调用该函数

ConfigurePoolLimits $comAdmin 1000000