Solved

Script to change ad office attribute bulk

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How ldap located a Domain controller? 22 77
Open new WPF windows - powershell 4 37
Strip 'trailing' spaces 10 33
Deploying MSI package with GPO 3 24
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
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 …

734 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