Solved

PowerShell Setting of Home Directory Issues

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

20 Experts available now in Live!

Get 1:1 Help Now