Powershell termination script to remove manager from direct reports

Working on a powershell script for termination and I want it to remove the terminated user from the manager field of any users that currently have it.  I know I can't use the direct reports data as it doesn't link correctly.
Looking essentially for a script that would filter all users based on the manager field and then based on those filtered users, set the manager field to $null.
I have tried commands to the effect of
get-aduser -filter { manager -eq "<username of term'd user>"}
and also
get-aduser -ldapfilter '(manager=<username of term'd user>)'
But both commands come back blank even though I know there are users in AD with that manager.
I've searched the interwebs, but can't seem to find this specific item.
Any assistance would be greatly appreciated

Manager isn't one of the default properties returned by Get-ADUser, which is why you need to specify it.
What happens if you run this:
Get-ADUser -Filter "Manager -eq 'CN=Walter White,OU=Users,OU=*DECOM,OU=*GLOBAL,OU=*Furmanite,DC=fwwi,DC=net'"
I've never had an OU with a '*' in it, perhaps that's causing your problems.
Don't retire TechNet! -
(Don't give up yet - 13,225+ strong and growing)
Well, looks like you're right on the "*".  I moved Walt to the default User OU in AD and it worked:
[PS] C:\_install\scripts>get-aduser -filter "Manager -eq 'CN=Walter White,CN=Users,DC=fwwi,DC=net'"
DistinguishedName : CN=Jesse Pinkman,OU=Information Technology,OU=Houston,OU=Zohno,OU=Test,OU=*GLOBAL,OU=*Furmanite,DC=
fwwi,DC=net
Enabled : True
GivenName : Jesse
Name : Jesse Pinkman
ObjectClass : user
ObjectGUID : 56f971e6-2f95-431e-b3e0-5275c7546d4d
SamAccountName : jpinkman
SID : S-1-5-21-2931136610-426972087-2848873238-67126
Surname : Pinkman
UserPrincipalName : [email protected]
DistinguishedName : CN=Optimus Prime,OU=Houston,OU=Zohno,OU=Test,OU=*GLOBAL,OU=*Furmanite,DC=fwwi,DC=net
Enabled : True
GivenName : Optimus
Name : Optimus Prime
ObjectClass : user
ObjectGUID : f19d0172-ee15-47db-bdb7-2977acd85907
SamAccountName : oprime
SID : S-1-5-21-2931136610-426972087-2848873238-67127
Surname : Prime
UserPrincipalName : [email protected]
DistinguishedName : CN=Johnny Manziel,OU=Houston,OU=Zohno,OU=Test,OU=*GLOBAL,OU=*Furmanite,DC=fwwi,DC=net
Enabled : True
GivenName : Johnny
Name : Johnny Manziel
ObjectClass : user
ObjectGUID : ac8f5a13-8742-4a2f-a476-a1e8175ade07
SamAccountName : jmanziel
SID : S-1-5-21-2931136610-426972087-2848873238-67128
Surname : Manziel
UserPrincipalName : [email protected]
Your original recommendation works when Walt is in the default Users OU as well.

Similar Messages

  • Help with a Requirement for a manager's direct reports

    Hi All,
    I have a requiremnt for a manager to be able to see his direct reports in US alone.
    ex: A manager is in US, he has reportees who are in US, and also reportees who are in other countires on other foreign assignments..but this requirement shld give him only the reportees present in US and exclude reportees who are working in other locations.
    i have a solution kinda..but not sure its the right way..i am thinking first pull out all his direct reports and then filter out based on all those employees for whom.. IT0710 is maintained.But i am not sure, if IT0710 is alone the determining factor for employees on foreign assignment..
    pls advice.

    Hi Mike,
    According to your description, I understand you have delegate permission and you want to create a rule to move message to your inbox.
    If I misunderstand your concern, please do not hesitate to let me know.
    Depending on my research and testing, it's unpossible. Rules are processed during send/receive or when selected manually so hooking it to the "Mark as Read" action would require a completely separate processing mechanism.
    Best Regards,
    Allen Wang

  • Removing iFrames from the reports

    Hi Gurus,
    We have drop down 1)Time Frame having values WTD,MTD,QTD,YTD
    2)Measure having values Product,Service,Product & Service
    We are picking the value from the drop down and using iframes to call those different reports like Product WTD or Product MTD etc.
    We have created the different measures for product,service,prod and service for WTD MTD(level based measures in RPD).
    Now we want to remove the customization and javascript code of iFrames as we want to upgrade to OBIEE.
    Any help in this regard.
    Regards,
    P

    What is your structure in BMM? Is that WTD, YTD, etc is value in one of your dimension?
    If yes, just simply add a dashboard prompt, if not, you can try: [http://carpediemconsulting.wordpress.com/2008/05/07/report-selection-using-dashboard-prompts/]
    -Will

  • Remove HTML from Interactive report download

    I have interactive reports where the column link on a specific column has to be dynamic, that means, it cannot be hard coded in the column link attributes. The following is an example of one such report query:
    case when d.object_type_description ='Business Service' then
    '< href="f?p='||:app_id||':183:'||:app_session||'::::P183_OBJECT_ID:'||d.id||'">'||d.object_name||'</>'
    when d.object_type_description = 'Real Time Event' then
    '< href="f?p='||:app_id||':162:'||:app_session||'::::P162_OBJECT_ID:'||d.id||'">'||d.object_name||'</>'
    else
       null
    end as "OBJECT NAME"As you see in the above example, the link on the "Object Name" column could either redirect to page 183 or to page 162 based on the "Object Type Description" column.
    The column attribute of the "Object Name" column has "Display Type" set to "Standard Report Column". That works perfectly fine in the UI of the report. However, if I download the IR data (in any format) from the Actions -> Download menu, the object name column values are downloaded with the HTML characters as:
    < href="f?p=15548:183:6072319179284::::P183_OBJECT_ID:255245470513999672860510787772603748464">JP010000</>where JP010000 is the object name.
    Is there a way I can strip the HTML from the column values in the downloaded files?
    I am using Apex 4.1.

    Rohit,
    You can define the link in the query, make it hidden, use the value as column link URL. So, your query will look like the following:
    d.object_name,
    case when d.object_type_description ='Business Service' then
        'f?p='||:app_id||':183:'||:app_session||'::::P183_OBJECT_ID:'||d.id
    when d.object_type_description = 'Real Time Event' then
        'f?p='||:app_id||':162:'||:app_session||'::::P162_OBJECT_ID:'||d.id
    else
       null
    end linkChange the display type of LINK column to Hidden. In column link, enter #OBJECT_NAME# as Link Text. Select URL as Target. Enter #LINK# as URL value. In APEX 4.2, you can do this in easier way by defining HTML Column Expression.
    Regards,
    Christina
    Edited by: cbcho on Sep 27, 2012 11:35 AM

  • Remove "zero" from word reports in nav 2015

    Hello Friends,
    I have a problem with reports made in Word nav 2015.
    When a texts is added to the salesline with no items or prices attached, the report generated in Word shows a "zero" at the end of the line for each field in the report.
    In the RDLC report builder there is a function BlankZero, how do you get this functionality in Word ?
    Hope you have some tricks to solve this issue :) 

    Hi
    you can use the function Module
    CONVERSION_EXIT_ALPHA_OUTPUT in the start routine
    to test this go to SE37  --- give the CONVERSION_EXIT_ALPHA_OUTPUT -
    >display -
    > F8
    in the input give 000000456
    and execute
    the out put will be 456
    for getting Zeros you can use
    CONVERSION_EXIT_ALPHA_INPUT--- to remove leading zeros
    Santosh
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:52 PM
    Edited by: Santhosh Nagaraj on Oct 29, 2009 10:54 PM

  • ProcessdpCommandEx error when adding or removing object from WebI report (based on BEX query) query panel object list

    Hi,
    We have WebI reports build on BEX using BAPI connectivity. When we are trying to add a object in query panel in a existing report we are getting this ProcessdpCommandEx error. But error does not appear when we add at the end of the list of objects already added.
    Can you calrify whether this could be some setting issue or it is a known bug?
    Can you share SAP Note No in case it is a known bug?

    Hi Avijit,
    This error occurs in case of any failure in the connectivity. It is like the data providers are not getting processed.
    You have mentioned that the issue does not come with newly created reports
    Are you creating new reports on migrated universe or a newly created universe?
    If issue only comes with migrated universe, please check if the connection has been migrated properly and required middleware and database connectors are in place.
    If connections are in place, try importing and exporting the universe once and check.
    In case, new report works fine with migrated universe, then you can simply try to re-point the universe by editing the query and can run it again and check.
    Regards,
    Yuvraj

  • How to remove # fields from my report

    Hi,
    In our Bex query, fields which have no data are displayed as '#'. because of this many fields are shown '#' since no data for those fields. As this looks odd we want in our report , these fields to be shown as blank ' '  instead of '#'. Is it possible to make those fields leave empty instead of showing up #.
    I have searched all the forum questions found similar questions but could not find a convincing answer .
    Please help required
    thanks & regards
    Krishna

    Hi
    you can use a macro to do this.
    You can find the following link for the proceedure to add a macro:
    http://wiki.sdn.sap.com/wiki/display/BI/SAPBWMacros--BExFormatting+Features
    and you can add a macro like for your requirement:
    Sub DelX()
    Dim c As Range
    For Each c In ActiveSheet.UsedRange
        With c
            If Replace(LCase(.Value), "#", "") = "" Then .Value = ""
        End With
    Next c
    End Sub
    Let me know if the Macro worked for you.
    Regards,
    Krishna Tangudu

  • Update Symbol and Symbol Script without removing from Document library

    Is there a way in fireworks CS5.1 to update a symbol and the corresponding symbol script without removing it from the document library like it suggests in the below article
    http://www.adobe.com/designcenter/fireworks/articles/frwcs3_richsymbol_print.html

    I have done some more research on this question and there appears to be no way to update a symbol script without removing it from the document library, hopefully this bug will be patched in the near future

  • A simple script that removes older packages from cache dir

    Hello all,
    I wrote a small bash script that removes packages (from cachedir /var/cache/pacman/pkg), older than the ones available in repositories (eg. if the current version of pacman is 2.6.3, it will remove pacman-2.6.2 from cachedir). It implements the functionality of debian's 'apt-get autoclean'.
    Get it from http://www.kegep.tuc.gr/~manolis/archlinux/cleanold.sh.

    thanks a lot for sharing this 

  • Removing "Other" From Login

    Hey,
    Just recently it started adding "other" to my login screen when I start up.
    I disabled the guest account and also tried the terminal command to remove accounts from the login menu. Does anyone know how else I can remove this?
    It's really annoying having to click my account to login rather than simply being able to type in my password

    according to macosxhints.com this terminal command should remove it
    sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWOTHERUSERS_MANAGED -bool FALSE
    I'm trying it now. Will update
    Ok, it worked. Cool deal. google and 20 minutes later
    Message was edited by: amsgator

  • Exchange 2010 SP3 Create Dynamic DL for Direct Reports

    I am not sure this is possible but if there is a will there is a way I guess.
    System: Exchange 2010 SP3 on Windows Server 2008 R2
    I am trying to see if there is a way to create dynamic DLs for Manager(s) direct reports.
    Example: Manager has 5 people that report directly to them, is there a way to make an dynamic email distribution list that will poll the direct reports as people leave or hired.
    I know I can create one manually but some depts. may have high turnover rates which increase overhead so I am just trying to simplify the process. I of course googled my question but not getting the results I intended.
    Thanks. 

    hi,
    as from above  i understand you are asking about creating an custom attribute and then referencing them .. if yes please check below command
    Get-Mailbox -OrganizationalUnit Sales | Set-Mailbox CustomAttribute1 "SalesOU"Now you can create an e-mail address policy for all recipients that have the CustomAttribute1 property that equals SalesOU, as shown in this example.
    New-EmailAddressPolicy -Name "Sales" -RecipientFilter { CustomAttribute1 -eq "SalesOU"} -EnabledEmailAddressTemplates "SMTP:%s%[email protected] check this.. http://technet.microsoft.com/en-us/library/ee423541%28v=exchg.150%29.aspx
    MARK AS USEFUL/ANSWER IF IT DID
    Thanks
    Happiness Always
    Jatin

  • Review Activity Notification to Direct Reports

    We have a workflow, thats creates review activity to manager of useraffected. Works Perfectly.
    But in some cases, aduser have direct reports, and SCSM aggregate this people to reviewers, from a review activity and send email to manager and direct reports.
    I was investigating, y apparently direct reports and manager are "reviewers".
    Is this situation a bug, an error, or it's OK?
    There is anyway to avoid that direct reports are agregated to reviewers?
    Thanks

    Hi,
    How do you determinate direct report users?
    Cheers,
    Marat
    Site: www.scutils.com 
    Twitter: LinkedIn:
    Graveyard:
    from Ad properties. The users in active directory have direct reports

  • How to remove multiple identified computers from direct membership collection..

    I have been askedd to remove a list of computers provided in a text file from a direct membership collection, normally this would be easy and I would use Collection Injector as it is a great solution which is pretty much foolproof, however for some reason
    that is totally beyond me and who knows why, I have been told to see if there is a script to perform the same functionality, but why reinvent the wheel.....go figure
    so in essence, does anyone know of a script to accomplish this????I can find them for a single computer but not for a list based solution, any help greatly appreciated
    regards
    many thanks

    Also, if you are looking to remove a llist of machines from a collection. Why don't you try writing a query?
    some like...
    select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System whereSMS_R_System.NetbiosName not in ("null")
    here put the list of computers in the not in list..
    ----Please vote if this is helpful----- -----Knowledge is Power-------- Ajo Abraham [MCP] [MCTS]
    Maybe because you can't remove computers from a collection with a select statement? You could do it in SQL but that would be VERY unsupported.
    John Marcum | http://myitforum.com/myitforumwp/author/johnmarcum/

  • I am using 10.6.8 and I cannot get an Imac to appear in workgroup manager, the mac is bound to both AD and OD. I have removed the bindings, rebuilt the mac and also removed it from bot system but still it does not appear in OD in work group manager.

    I have a mac which is connected to a network and is bound to both OD and AD with no issues on my server when I try to manage it through Workgroup manager it does not appear.
    I have unbound it , removed it from both systems completely and even rebuilt it but it still does not appear in WGM.

    If your server is 10.6 and your client is 10.7 you'll have to add it manually to WGM
    via mac address.  10.7 clients don"t automatically appear in 10.6 server wgm

  • Remove items from the Tools menu in the Service Manager console

    Hi. 
    I know I have see a post regarding this before, but just wanted to put it out these once again.  I'd like to remove items from the Tools menu in the Service Manager console - specifically My Notifications and Create Change Request.  This is because
    the former allows a user to create notification subscriptions in incorrect Management Packs, and the latter because we are not using Change Management yet.  Does anyone have any information on how to achieve this?
    Cheers
    Shaun

    how to customize tools tht are displayed in tool menu
    http://technet.microsoft.com/en-us/library/jj134147.aspx#BKMK_tools

Maybe you are looking for

  • Account assignment to Profit. segment not supported with this G/L account

    Hello Guru,             we have activated the COPA- Costing based. after activation while doing the Shipping Cost calculation thr T.C VI01 system is throughing error message Account assignment to Profit. segment not supported with this G/L account Me

  • Music Not Showing up in Library

    I have the latest edition of iTunes and just discovered something odd. Sometimes I drag & drop folders of MP3 music that I got from other sources directly into my iTunes Music folder. I just realized that this music does not show up in my Library in

  • Trying to find recently viewed demo video on CS6 features

    Hey All, For the life of me i cannot find a video i watched last week on the new features of cs6 photoshop. I have been searching for the last hour on adobe tv for the one i am after and cant find it. It features the content aware move tool, fixing s

  • JTree Problem again

    Deat 7rst, Sorry, I want to ask you about the same problem. if I want to display a difference components from difference node in JTree, how the code I must use? I already understand about the code that you give to me. But I still confuse if many node

  • Cursor fetch with multiple rows

    I have been given code which, effectively, looks like this: declare   cursor cTest is select * from (select 'one' from dual union all select 'two' from dual);   lvText varchar2(10); begin   open cTest;   fetch cTest into lvText;   close cTest;   dbms