Zoho Banner September 2011

Archive for October, 2012

If you come across this error when using Powershell to delete an object, it is most likely because the object has child objects associated with it.  The most obvious example is computer objects that have print queue, service connection point, RRAS or various other types of child objects.  The workaround is to determine the child object (to see if it might be required) and then to delete the objects recursively as shown below.

In this example we have a computer object named “Foo”.  If we try and delete it using the Powershell AD cmdlet Remove-ADComputer we see the “leaf object: error.


We can then use some other Powershell goodness to determine the type of child object that we have.  In this case a service connection point object.


Once we’re happy that deleting the child object won’t cause any other issues, we can use the Remove-ADObject cmdlet together with the –Recursive switch to delete both the computer and the service connection point objects.


Recently I was doing some testing with a new Exchange 2010 Receive Connector and wanted a method to check how many messages it was processing.  I came up with the following Powershell snippet that seems to work well.

$i = 0
do {
    $now = get-date
    (Get-MessageTrackingLog -ResultSize unlimited -Start "11/10/2012 3:00PM" -End $now -Server MYSERVER `
    | ? {$_.connectorid -eq "MYSERVER\SMTP Relay"}).count
    sleep 30
    $i = $i + 1
until ($i -eq 100) 

The script uses the “do until” method to query the message tracking logs on a specific server at 30 second intervals for instances of the Receive Connector and displays the count.  It does this a hundred times (or until you stop the script).