Solved

Script to change ad office attribute bulk

Posted on 2016-10-14
4
19 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 14

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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 …

707 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

17 Experts available now in Live!

Get 1:1 Help Now