SetACL Owner Computer Object

Guys. 

I have knocked this script up in AD Powershell which sets the owner of an AD Computer to Domain Admins. I am trying to get the same kind of script working but via Quest Powershell. No matter what i knock up its not working. 


Anyone got any suggestions to Quest Powershell this script? 

Import-Module ActiveDirectory

# Specify the computer name
$computerName = "AD-Computer-Name"

# Get the computer object from Active Directory and retrieve its DistinguishedName
$computerObject = Get-ADComputer -Filter {Name -eq $computerName} -Properties DistinguishedName

if ($computerObject) {
    $dn = $computerObject.DistinguishedName

        $acl = Get-Acl -Path "AD:$($DN)"
      
        $acl.SetOwner($user)
        Set-Acl -Path "AD:$($DN)" $acl

} else {
    Write-Output "Computer not found in Active Directory: $computerName"
}

Top Replies

  • Hi   

    The below should work, or at least give you a pointer.

    # Specify the computer name
    $ComputerName = "SQL001"
    
    # Specify the owner
    $Owner = "Domain Admins"
    
    # Get the computer object from…