Solved

Script to change ad office attribute bulk

Posted on 2016-10-14
4
25 Views
Last Modified: 2016-10-14
Hi i am trying to change the office ad attribute for 100 users in a csv
0
Comment
Question by:Jorge Ocampo
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 250 total points
ID: 41844313
Try..
Import-Module Activedirectory
Import-csv c:\input.csv | %{Set-ADUser $_.User -Office $_.Office}

Open in new window

Sample input csv file
User,Office
UserA,OfficeA
UserB,OfficeB

Open in new window

0
 
LVL 15

Assisted Solution

by:Todd Nelson
Todd Nelson earned 250 total points
ID: 41844316
This should accomplish your request...

Import-Module ActiveDirectory
Import-Csv "C:\Users.csv" | ForEach-Object { Set-ADUser -Identity $_.Name -Office $_.Office }

Open in new window

0
 
LVL 2

Author Comment

by:Jorge Ocampo
ID: 41844327
asweome thanks guys any reason why my below query doesnt run?

Get-ADobject -Filter "*" -Properties mail,office | Where-Object {$_. -like "OFFICE12"} | Export-Csv C:\Temp\TEMP\file12.csv
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41844348
If you are trying to filter office attribute the you need to use $_.Office instead of $_.
Try using
Where-Object {$_.Office -like "OFFICE12"}

Open in new window

or
Where-Object {$_.Office -Match "OFFICE12"}

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
In-place Upgrading Dirsync to Azure AD Connect
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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