VMware Aria Automation Orchestrator

 View Only
  • 1.  delete cpmputer account with Recursive

    Posted 9 days ago
    Edited by Jason McClellan 8 days ago

    hi

    Recently I have been having difficulties deleting  Computer Account object from  AD
    Sometimes it works and sometimes it doesn't and the problem is related to Recursive (hope I'm defining correctly)
     
    If I run this command through powershell the object is deleted
    Get-ADComputer -Identity $vmName | Remove-ADObject -Credential $cred -Recursive -Confirm:$false
    But via javascript in VRO unfortunately does not work
    This is the javascript command
    var comp = System.getModule("kuku.com").getComputerAccountFromForest(vmName,adHost);
    System.log(comp)
    if (vmName.toLowerCase() == comp.name.toLowerCase()){
            System.log("Found Computer: "+comp.name);
    }

    comp.destroy();
    Again I mention, if there is no Recursive problem the command works properly

    THX 


  • 2.  RE: delete cpmputer account with Recursive

    Posted yesterday

    Hi there,

    Unfortunately, there are a few missing or incorrect details in the question.

    First, there's no built-in action called `getComputerAccountFromForest`. It seems like you might have written it yourself, so we can't determine what it returns. I'm guessing it probably returns a single or an array of AD_Computer objects, since that's the only class with a `destroy()` method.

    Second, `Get-ADComputer -Identity $vmName` returns a single object, so there's no need for a recursion.

    Third, in your example, `comp.destroy()` should be inside the IF statement so that it only deletes the computer object if it's found.

    Since you likely want to delete a specific computer object from AD once found, I'm not sure which recursive function you need. Ensure that step 3 is corrected, and everything should function as intended.

    PS. I think destroy() method requires a boolean parameter following the vRO's API.



    ------------------------------
    If you find the answer helpful, please click on the RECOMMEND button.

    Please visit my blog to get more information: https://www.clouddepth.com
    ------------------------------