Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Script to change ad office attribute bulk

Posted on 2016-10-14
4
Medium Priority
?
33 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 1000 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 16

Assisted Solution

by:Todd Nelson
Todd Nelson earned 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

596 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