Remove a COM+ Application

Author Message
Chrisnach

  • Total Posts : 3
  • Scores: 0
  • Reward points : 0
  • Joined: 2/4/2011
  • Status: offline
Remove a COM+ Application Friday, February 04, 2011 9:22 AM (permalink)
0
Hello,
 
I have a vbs file to remove a Com+ app. but when I convert it to PowerShell and remove the item and  use $oApplications.savechanges.
The com+ app isn't removed? Why? Thx.
 
#1
    Chrisnach

    • Total Posts : 3
    • Scores: 0
    • Reward points : 0
    • Joined: 2/4/2011
    • Status: offline
    Re:Remove a COM+ Application Friday, February 04, 2011 9:27 AM (permalink)
    0
    vbs is similar to this one
     
    On Error Resume Next

    For Each objItem in colItems
    ' Create an instance of COMAdmin Catalog
    set cat = CreateObject( "COMAdmin.COMAdminCatalog" )

    ' Reference the Applications Collection
    Set apps = cat.GetCollection("Applications")

    ' Retrieve the data
    apps.Populate

    ' Loop from upperbound to lower since the Remove method
    ' triggers an automatic reindexing.
    For i = apps.Count - 1 to 0 step -1
    ' query application collection x for name and compare
    if ( apps.Item(i).Name = "MYAPPNAME") then
    ' we have a match, nuke it
    apps.Remove (i)
    End If
    Next
    'commit changes
    apps.SaveChanges
    Next 
    PS1
     
    #Set the current computername
    $sComputer = gc env:computername
    #Set the Com+ Application name
    $COMPlusAppName = "appname"
    #Set a catalog object
    $Catalog = New-Object -comobject COMAdmin.COMAdminCatalog
    #connect with the current catalog
    $Catalog.connect($sComputer)
    #retrieve all the com applications
    $oapplications = $catalog.getcollection("Applications")
    #populate the list
    $oapplications.populate()
    #Set the start index
    $a = 0
    #iterate through the list
    foreach ($oapplication in $oapplications){
    #find the application      {
    if($oapplication.name -eq $COMPlusAppName){
    #remove it
    $oapplications.remove($a)
    }
    #Next item -> index +1
    $a = $a + 1
    }
    #Save the changes
    $oapplications.SaveChanges
    #show result
    foreach ($oapplication in $oapplications){
    Write-Host $oapplication.name
    }
    #inform the user - done
    $f = new-object -comobject wscript.shell
    $g = $f.popup("Done",0,"FOBreset",64)
     
    Also it's a conversion from VBS so if there is a proper way of doing it in PS then please post it. Thx.
    <message edited by Chrisnach on Friday, February 04, 2011 9:47 AM>
     
    #2
      Chrisnach

      • Total Posts : 3
      • Scores: 0
      • Reward points : 0
      • Joined: 2/4/2011
      • Status: offline
      Re:Remove a COM+ Application Friday, February 04, 2011 11:30 AM (permalink)
      0
      found it:
      $oapplications.SaveChanges()
      io
      $oapplications.SaveChanges
       
      ok, thx.
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9