0

如何通过 powershell 脚本将 COM PLUS 组件的事务隔离级别设置为任何。我正在尝试以下代码

  $comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
    $apps = $comAdmin.GetCollection(“Applications”)
    $apps.Populate();

    foreach($app in $apps)
    {
    Write-Host $app.Name
        if($app.Name -eq $ApplicationName)
        {
         $components = $apps.GetCollection("Components",$app.key)
         $components.Populate()


             foreach ($component in $components)
             {
                $componentName = $component.Name;                
                Write-Host "*"$componentName;   
                if($componentName -eq "WDA_DUP.Generic13")
                {
                $component.Value("TXIsolationLevel")=COMAdminTxIsolationLevelAny;
                }                  
             } 
        }   
    }

但没有解决目的。请帮助我:)`

4

1 回答 1

1

工作脚本:

$ApplicationID = "{C0D4E2A4-CAC1-47BA-819C-EAB73E978FDF}"
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
$apps = $comAdmin.GetCollection(“Applications”)
$apps.Populate();

foreach($app in $apps)
{
  #Write-Host $app.Name
  #Write-Host $app.Key
  if($app.Key -eq $ApplicationID)
  {
      Write-Host $app.Name
      $components = $apps.GetCollection("Components",$app.key)
      $components.Populate()
      foreach ($component in $components)
      {
        $componentName = $component.Name;                
        Write-Host "Set "$componentName;   
        $component.Value("TxIsolationLevel")=2
      } 
      $components.SaveChanges()
  }   
}
于 2018-07-24T21:10:30.510 回答