Share via


MSFT_ComputerToComputerGroup.Computer Property

Gets the MSFT_Computer object associated with a specific MSFT_ComputerGroup object.

 MSFT_Computer MSFT_ComputerToComputerGroup.Computer

Access

Read-only

Return Value

MSFT_Computer object

Examples

The following example shows the use of the MSFT_ComputerToComputerGroup class. The class supports association queries and, in most cases, you do not need to explicitly use its properties.

'*********************************************************************
' Routine: Function AddNonWindowsComputerToGroup
' Purpose: Creates an association object binding a non-Windows computer
'          to a group.
' Arguments: The server running MOM, computer group GUID, computer GUID.
' Returns: The number of computers scanned.
'
'**********************************************************************
Const TYPE_NONWINDOWS = 8192

Function AddNonWindowsComputerToGroup(strMOMServer, strGroupGUID, strComputerGUID)
    Dim objAssocClass
    Dim objComputer, objComputerToComputerGroup, objComputerGroup
    Dim blnSuccess

    blnSuccess = False

    ' get the computer and group
    Set objComputer = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_Computer='" & strComputerGUID & "'")
    Set objComputerGroup = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_ComputerGroup='" & strGroupGUID & "'")

    If ((objComputer.Type = TYPE_NONWINDOWS) And (objComputerGroup.Type = TYPE_NONWINDOWS)) Then

        ' get the association class
        Set objAssocClass = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_ComputerToComputerGroup")

        ' create an object instance from the association class
        Set objComputerToComputerGroup = objAssocClass.SpawnInstance_()

        ' construct the object reference strings
        strComputerGUID = "MSFT_Computer.GUID='" & strComputerGUID & "'"
        strGroupGUID = "MSFT_ComputerGroup.GUID='" & strGroupGUID & "'"

        ' set the association object properties, and save back to WMI
        objComputerToComputerGroup.Computer = strComputerGUID
        objComputerToComputerGroup.Group = strGroupGUID
        Call objComputerToComputerGroup.Put_()
        blnSuccess = True
    End If

    Set objComputer = Nothing
    Set objComputerGroup = Nothing
    Set objAssocClass = Nothing
    Set objComputerToComputerGroup = Nothing

    AddNonWindowsComputerToGroup = blnSuccess
End Function
  

Requirements

Platforms: Requires Windows 2000 Server or later

Version: Requires MOM 2000 SP1 or later

See Also

MSFT_ComputerToComputerGroup Class