Solved

PowerShell Setting of Home Directory Issues

Posted on 2014-11-17
3
145 Views
Last Modified: 2014-11-18
I am trying to take my script that works just fine for individual AD User Accounts and get it to read from a text file a list of
AD user names and then update their Home Directory within Profile HomeFolder.

Thanks again for the help

Script that works for individual AD User Accounts:

Set-ADUser -identity "UserName" -homeDrive h: -homeDir "\\ServerName\HOME"

Script that is not working properly:

Set-ADUser -identity ((Get-Content users.txt) -replace '$', '$') -homeDrive h: -homeDir "\\ServerName\HOME"

Error Msg:

Set-ADUser : Cannot find an object with identity: 'MedreconTest$' under:
'DC=test,DC=com'.
At C:\disabledshares\SetHomeDrive1.ps1:1 char:1
+ Set-ADUser -identity ((Get-Content users.txt) -replace '$', '$') -homeDrive
h: - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : ObjectNotFound: (MedreconTest$:ADUser) [Set-ADUs
   er], ADIdentityNotFoundException
    + FullyQualifiedErrorId : Cannot find an object with identity: 'MedreconTe
   st$' under: 'DC=whhs,DC=local'.,Microsoft.ActiveDirectory.Management.Comma
  nds.SetADUser
0
Comment
Question by:robertarenson
[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
3 Comments
 
LVL 16

Accepted Solution

by:
Joshua Grantom earned 500 total points
ID: 40448937
you shouldnt need any dollar signs in the name


$users = Get-Content C:\users.txt | foreach {
Set-ADUser -identity $_ -homeDrive h: -homeDir "\\ServerName\HOME"
}

Open in new window

0
 

Author Closing Comment

by:robertarenson
ID: 40451116
Thank you so very much, that did the trick
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40451121
Glad to help
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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