Solved

PowerShell Setting of Home Directory Issues

Posted on 2014-11-17
3
138 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
  • 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

Is Your AD Toolbox Looking More Like a Toybox?

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

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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