Link to home
Start Free TrialLog in
Avatar of robertarenson
robertarenson

asked on

PowerShell Setting of Home Directory Issues

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
ASKER CERTIFIED SOLUTION
Avatar of Joshua Grantom
Joshua Grantom
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robertarenson
robertarenson

ASKER

Thank you so very much, that did the trick
Glad to help