Solved

Change manager in Powershell

Posted on 2013-06-04
4
309 Views
Last Modified: 2013-07-03
Hey

I have a manager "Alex Alexsen"... I would like to change all users who have "Alex Alexsen" as manager to "Viggo Viggosen" using powershell

Thanks in advance

Mike
0
Comment
Question by:mikeydk
4 Comments
 

Author Comment

by:mikeydk
ID: 39218458
Viggo Viggosen as manager :)
0
 
LVL 10

Assisted Solution

by:Prashant Girennavar
Prashant Girennavar earned 166 total points
ID: 39218707
Try below code,

import-module activedirectory
get-aduser -filter * -searchbase "dc=contoso,dc=com" | select-object -Property samaccountname | %{set-aduser $_.samaccountname -Manager <NewManagerName>}

Open in new window


Please modify DN (DC=contoso , DC=Com) , according to your need ,  {Please be careful to select the right DN}

<NewMangerName> -->Your New manager Samaccount Name goes here.

Hope this help

Thanks,

-Prashant Girennavar.
0
 
LVL 7

Assisted Solution

by:BT15
BT15 earned 167 total points
ID: 39219637
pretending that the Windows ID for Alex Alexsen is alexa and the ID for Viggo Viggosen is viggov:

import-module activedirectory
get-aduser -Properties manager -filter {manager -eq "alexa"} | % {set-aduser $_.samaccountname -manager (get-aduser viggov).distinguishedname}

Open in new window

0
 
LVL 40

Accepted Solution

by:
Subsun earned 167 total points
ID: 39219659
Try this..

Replace AlexAlexsen wiwth samaccountname of Alex Alexsen
Replace ViggoViggosen wiwth samaccountname of Viggo Viggosen

I have added parameter -WhatIf for testing, you can remove it for applying changes..

 $Manager = (Get-ADUser "AlexAlexsen").DistinguishedName
 Get-ADUser -Filter *  -properties manager | ? {$_.manager -eq $Manager} | Set-ADUser -Manager "ViggoViggosen" -WhatIf

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now