Remove-ADUser when object is a tree

Hi,
I have a problem with some AD user objects.
If some AD users have ActiveSync device registered in Exchange, their user object is a "tree" object rather than a "leaf" object.
Therefore, when I try to delete such an AD user object, I get error below:
+ $users | % {Remove-ADUser -Identity $_.distinguishedname}
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (CN=John Doe...C=acme,DC=local:ADUser) [Remove-ADUser], ADException
    + FullyQualifiedErrorId : The directory service can perform the requested operation only on a leaf object,Microsoft.ActiveDirectory.Management.Comm
   ands.RemoveADUser
My only solution is to use GUI (dsa.msc) and delete users one by one from there. The GUI shows warning, but continuing on warning gets the job done. So, I have three questions.
1. How can I test if the object is a leaf?
2. How can I test if the object is a tree?
3. How can I delete AD user in Powershell when user object is a tree?
Thanks in advance,
Les

I'm not sure how to test for that.
I'd just use Remove-ADObject for removing all users or do something like this to cover all bases:
$user = Get-ADUser username
try {
Remove-ADUser -Identity $user.DistinguishedName -ErrorAction Stop
} catch {
Remove-ADObject -Identity $user.DistinguishedName -Recursive
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)

Similar Messages

  • How to Remove a Report Object from a Category Without Deleting It?

    I'm trying to "remove" a report object (in this case a Webi Report) from a Personal Category. However, I've found that when I right-click on the report within the Category and choose "Organize >> Delete", not only does it remove the report from the Category, it also deletes the "source" report from it's original location... not good.  (NOTE: If I try this as a user without rights to delete report objects, I don't even get the "Organize >> Delete" option, as would be expected based on the behavior I'm seeing.)
    Does anyone know if there is a way to "Remove" report objects from Categories without deleting the report from its original location?  The only option I can think of is to simply recreate (copy/paste) the whole category with all of its components (less the undesired report object) and then delete the original Category.
    Thank,
    Josh
    Edited by: Josh Crawford on Sep 9, 2010 9:25 AM

    Hi,
    This is much easier than it looks like, although it's not intuitive.
    For example, when some webi is in a category, categories where the webi is linked are underlined in blue:
    If you click in those blue marked categories and click Accept, you're unlinking the webi/report/dashboard from that category:
    -->
    Hope it helps
    Alberto

  • Function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    I want to call Stored Procedure that return records and output parameter, from CVI
    I can get output parrameter but when I want to get records stream I recieve following wrror:
    function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    in Stored procedure I create table variable and and insert into string values
    when I remove usage of table variable the error desappear

  • How to remove Business content objects that are not required?

    Hi all of you,
    I had extracted some of the objects from business content from FI such as General LEdger and Asset Accounting. After extracting it, my c drive is full and I am not able to open any other file. So I want to remove these FI objects that I had extracted from Business Content. Can any one please guide as to how should I remove these already loaded Business content objects?
    Thank you.
    TR.

    Hi,
    You can right click on the objects (unused) and delete.
    actually when you activate business content its version is changes from "D" Delivered to "A" Active but these objects will always be available as D version to you. Even if you delete the activated objects now & need those in future you can reactivate them.
    hope it helps
    Regards
    Vikash

  • How to bind an object to JNDI tree in iAS?

    Hi all,
    When I try to bind a string object to jndi tree, the following exception
    occurs:
    javax.naming.NamingException: Unable to get object instance from reference.
    Roo
    t exception is javax.naming.NamingException: Can't bind instance of class
    java.lang.String
    at com.netscape.server.jndi.RootContext.bindCtx(Unknown Source)
    at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
    at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
    at javax.naming.InitialContext.rebind(InitialContext.java:385)
    at jsp.APPS.bmx.test2._jspService(test2.java:76)
    at jsp.APPS.bmx.test2.service(test2.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    The code fragment is:
    Context ctx = new InitialContext();
    String str = "hell,every one!";
    ctx.rebind("abc", str);
    Can anyone give some help? Thanks in advance.
    Johnson

    To bind an object into the JNDI tree check the documentation here:
    http://e-docs.bea.com/wls/docs81/jndi/jndi.html#475702
    If this is to be used by all your applications that you deploy on the server check out the startup/shutdown class documentation here:
    http://edocs.bea.com/wls/docs81/ConsoleHelp/startup_shutdown.html
    Cheers
    IV

  • Removal of Inactive Objects from Roles

    Dear All,
    Please let me know, how to remove the inactive objects in  roles.
    Thanks in Advance,
    Thiyagu

    Hi Thiyagu.
    In addition to Bernhard & Arpan's inputs,Since the number of Manually maintained objects (Inactive Status) is very less in a role, the majority of them are left behind for manual clean up. As a best practice , Inactive objects are retained in roles to have some history in case of any audits and also to maintain the object dependency to see why the object got into the role ... It helps any new security admin's to steer through audits when old timers move out ...
    Hope it helps.
    Rgds,
    Sri

  • I have songs on my iPhone 6 that I can't remove and when I plug into iTunes and go to "Summary" and "On This Device" the songs don't show up but they are on my phone. How do I remove them? Not even sure how they got on actually.

    I have songs on my iPhone 6 that I can't remove and when I plug into iTunes and go to "Summary" and "On This Device" the songs don't show up but they are on my phone. How do I remove them? Not even sure how they got on actually since I have a iTouch and keep all my music there. HELP!!

    Have you tried deleting the songs from Settings?
    Settings -> General -> Usage -> Manage Storage (not the iCloud link!) -> Music and then click Edit to enable you to be able to delete.

  • 3750x Stack UTIL-3-TREE: Data structure error--attempt to remove an unthreaded node from a tree

    A Cisco Stack 3750X switch report the following error message:
    %UTIL-3-TREE: Data structure error--attempt to remove an unthreaded node from a tree.
    every minute +-20 sec
    Cisco IOS Software, C3750E Software (C3750E-IPBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)
    analog bug: https://tools.cisco.com/bugsearch/bug/CSCsz93221

    WS-C3750G-24PS-E C3750-IPBASEK9-M version 12.2(53)SE2
    After implementing 802.1x with Avaya IP phones
    %UTIL-3-TREE: Data structure error--attempt to remove an unthreaded node from a tree
    Port then fails authentication and goes into vl-err-dis

  • How we can remove  one authorization object from multiplt roles

    How we can remove one authorization object from multiplt roles

    > Correct me if I am wrong !!
    O.K., Here I go
    > But if the object is maintained in SU24 and if you use Expert mode for generation of the role then again those objects may be pulled.(make sure you never use expert mode once you delete the objects)
    Actually using expert mode and choosing 'edit old status' is the only way to avoid objects being 'pulled in' after menu changes.
    > As jurjen said, you may download the tables and instead of deleting the object from the excel sheet, change the value of the object in column "DELETED" = X, by doing this only the objects get inactivated(but remain in PFCG).
    I am not speaking of downloading tables but about downloading roles from PFCG. This will not get you a spreadsheet but a flat textfile. If you whish to set the object status to deleted you'll have to swap the space on position 207, right behind the 'U, S, G' flag,  with an 'X' for all corresponding lines.
    Jurjen

  • Moving Images objects to another tree

    Is it possible to move or recreate the workstation image object from one
    tree to another. I'm migrating from an NW6 SP5 cluster to NW6.5 SP4
    cluster. Zen 4.0.1 IR7 has already been installed.

    [email protected] wrote:
    > Is it possible to move or recreate the workstation image object from one
    > tree to another. I'm migrating from an NW6 SP5 cluster to NW6.5 SP4
    > cluster. Zen 4.0.1 IR7 has already been installed.
    not any supported ways.. you could take a look at coolsolutions for some
    edir tools
    If you have already compiled drivers or have linux.2 please put them on
    http://forge.novell.com/modules/xfmo...ect/?zfdimgdrv
    Live BootCd and USB Disk from Mike Charles
    http://forge.novell.com/modules/xfmod/project/?imagingx
    eZie http://forge.novell.com/modules/xfmod/project/?ezie
    Marcus Breiden
    If you are asked to email me information please change -- to - in my e-mail
    address.
    The content of this mail is my private and personal opinion.
    http://www.edu-magic.net

  • I can't get my iphone to add OR remove photos when syncing

    I can't get my iphone to add OR remove photos when syncing

    darn.
    Move <G>
    seriously, keep asking. someone here will know and i'll learn something

  • Remove MC when leaving the frame

    Hi I have a frame that AS this:
    this.createEmptyMovieClip("news",1)
    news.loadMovie("news.swf")
    when i click on a btn and gets to another frame this news.swf
    file still stays on top of other elements.
    is there a way to remove it when i'm leave the current frame?
    (thanks in advance)

    heheh kglad, thanks again. that's what i thought and it's
    good to have you to back that up.
    actually i decided to load movie into a pre-created empty mc
    instead of using createEmptyMovieClip
    then the swf disappear after changing frame. guess that
    solved the problem.

  • Device removal error when flash drive is plugged in

    I have a 1GB flash drive that I have used for a while with my Windows XP desktop. I switched from a PC laptop to a Mac Book Pro running Leopard. But the Mac Book gave me the drive removal error when I tried to use the flash drive. The PC desktop worked with the drive just fine. So I backed up the flash drive and reformatted it in FAT32. Then I reloaded the files. For a short while I had no problem with the Mac Book. Now I am getting removal errors again. I have been careful not the remove the drive, either from the PC or or the Mac Book, without going through proper procedures. It does no good to "repair" the drive from the Mac Book. Any suggestions?

    Maybe:
    http://www.macobserver.com/tmo/article/usb-3.0-hard-drives-can-cause-wi-fi-inter ference
    Re: 2012 Mini Bluetooth/USB3 Interference
    http://www.intel.com/content/www/us/en/io/universal-serial-bus/usb3-frequency-in terference-paper.html
    usb 3.0 interface for 2010 Mac Pro running Yosemite?

  • How to remove an anchored object from paragraph

    Hi All,
    I have a paragraph which have inline anchored object.
    Is it possible to skip anchored object from the paragraph tagging it.?
    Need Some method using which I can remove the anchored object from paragraph.
    Regards,
    Alam

    Hi,
    To skip and to remove can differ, so you have to decide what is a goal.
    Removing this can as easy as calling find...replace method (app.findTextPreferences.findWhat = "^a")
    Jarek

  • [svn:fx-trunk] 8551: Fix for focusSkin and errorSkin to account for bogus bitmap snapshots when objects are 3D transformed .

    Revision: 8551
    Author:   [email protected]
    Date:     2009-07-14 11:31:50 -0700 (Tue, 14 Jul 2009)
    Log Message:
    Fix for focusSkin and errorSkin to account for bogus bitmap snapshots when objects are 3D transformed.
    Bugs: SDK-17766
    Reviewer: Glenn
    QE Notes: None
    Doc Notes: None
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-17766
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/ErrorSkin.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/FocusSkin.as

Maybe you are looking for

  • Whats GOING ON with Pubcenter!? ALL TIME LOW Revenue and Fill rate!

    Whats going on here? Since 3 weeks the revenue has has not picked up one bit! I got the same number of impressions last month but the revenue was X3 more! :'( WHAT IS GOING ON? Support has there is "no demand" due to season. What does that mean? Why

  • Internal error on startpage/admin

    This is a beginners question ;-) I have tried to install SP on my webserver, but no matter what I do I just can't seem to get it to work. I have installed J2SE 1.4.1 and have set the JAVA_HOME to the dir. Then I have installed Tomcat 4.1.12 on port 8

  • Flex app can't connect to the internet / server when uploaded?

    I made a simple app that submits a data via POST using the HTTPService. My problem is, when I Run the application from the Flash Builder IDE, and it opens in the browser as a local file, it interacts with my server (remote server) without any problem

  • Spilled liquid on MacBook Pro - won't start - any suggestions?

    spilled liquid on MacBook Pro - won't start - any suggestions?

  • Trouble understanding treemap question

    Okay, here is the question: Create 10,000 unique random key values in the range 10,000 to 100,000. Hold them in array key. Use Random class's nextInt(n) method to add a random offset to the last randomly value generated. Start with value 1. rn = rn +