Solved

PowerShell Setting of Home Directory Issues

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scannerā€¦
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ā€¦

738 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