Hello experts, I'm lost once again (as usual): I need to add a specific computer to a group in ADS. To to that, I've written the following script: (to be honest, I have modified a similar UDF that does the same thing for a user). The script crashes at command $Group.Add($Computer.ADsPath) and @serror says "The storage control block address is invalid" Can anybody of you show me what I'm doing wrong?

many thanks in advance!

Sam
 Code:
; ----------------------------------------------------------------------------------------------------------------------
; Adds given machine to Group passed to function
; ----------------------------------------------------------------------------------------------------------------------
Function AddComputerToGroup($DomainName, $ComputerName, $GroupName)	
  ;Creating machine and Group objects
  $Computer = GetObject("WinNT://" + $DomainName + "/" + $ComputerName + ",computer")
  If $Computer = 0 ; User not found
    ConvertCOMError(@ERROR)
    $AddComputerToGroup = "Error " + @SERROR + " occured during GetObject(Computer)"
    Return
  EndIf
  $Group = GetObject("WinNT://" + $DomainName + "/" + $GroupName + ",group")
  If $Group = 0 ; Group not found
    ConvertCOMError(@ERROR)
    $AddComputerGroup = "Error " + @SERROR + " occured during GetObject(Group)"
    Return
  EndIf	
  ;Adding user to group
  $Group.Add($Computer.ADsPath)
  If @ERROR <> 0
    ConvertCOMError(@ERROR)
    $AddComputerToGroup = "Error " + @SERROR + " occured during Group.Add"
    Return
  EndIf	
  ;Writes the data to the SAM database from memory.
  $Group.SetInfo
  If @ERROR <> 0
    $AddComputerToGroup = "Error " + @SERROR + " occured during Group.SetInfo"
  Else
    $AddComputerToGroup = @SERROR + " adding Computer " + $ComputerName + " to group " + $GroupName
  EndIf	
  ;Object cleanup.
  $Computer = 0
  $Group = 0
EndFunction


Edited by Allen (2008-11-07 03:56 PM)
Edit Reason: added code tags